1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663
|
# Copyright (C) 2017-2018 ycmd contributors.
#
# This file is part of ycmd.
#
# ycmd 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 3 of the License, or
# (at your option) any later version.
#
# ycmd 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 ycmd. If not, see <http://www.gnu.org/licenses/>.
swagger: "2.0"
info:
title: ycmd
description: |-
ycmd is a code-completion & code-comprehension server.
ycmd presents a JSON/REST interface to clients over HTTP, validated by HMAC.
An instance of ycmd is started for each client application.
## General Notes
The REST interface typically uses HTTP POST requests and expects the payload
data to be a valid JSON document. The following general principles are
applied:
- All strings going into and out of the server are UTF-8 encoded.
- All lines end with `\n`.
- All line and column numbers are 1-based, not 0-based. They are also byte
offsets, not Unicode codepoint offsets.
- All file paths are full, absolute paths. If a file has not been written
to disk yet, supply a temporary path.
- All requests to the server must include an HMAC in the x-ycm-hmac HTTP
header.
- All responses from the server must be validated using the x-ycm-hmac
header.
## The example client
ycmd contains a simple example client in the `example` directory of the
source tree. It is written in pure Python with only minimal dependencies.
It contains trivial implementations of most endpoints and serves to
supplement this API documentation.
Consult `example/README.md` for instructions on getting it running.
## Starting the server
The ycmd server is typically started by a client in order to provide
services to it. Briefly, starting the server requires supplying some
configuration and initializing some security features (HMAC).
The server should be started with a supported version of Python.
The full list of command line options can be obtained by passing `--help`
to ycmd (e.g. `python -m ycmd --help`). However, the following
options warrant further discussion:
### `--options_file`
This mandatory option supplies the name of a file containing user options
data. This option (and thus the file) are mandatory, as they are required
to set the shared HMAC secret.
Once the server has read the options, the server deletes the options file.
Therefore, the client should typically create a secure temporary file (e.g.
`mkstemp`) which contains the options to be used.
The default options and their values are found in `default_settings.json`
within the ycmd codebase.
The file contains a JSON-formatted object, where the keys are the names of
options (with any `ycm_` prefix removed) and the values are the option
values.
The canonical list of supported user options can be found in
YouCompleteMe's `README.md`. The option values should have the `ycm_`
prefix removed.
The following additional options are required to be set by the client
application and should *not* be visible to the user:
- `hmac_secret`: The shared secret for HMAC authentication. This should be
16 bytes of random data with as much entropy as possible, encoded as a
base-64 UTF-8 string. Code for generating this in Python can be found
in the ycmd example client.
## HMAC
All requests to the server must include an HMAC in the x-ycm-hmac HTTP
header. The HMAC is computed from the shared secret passed to the server
on startup and the request/response body. The digest algorithm is SHA-256.
The server will also include the HMAC in its responses; you must verify it
before using the response. See the example client to see how it's done.
## Filetypes
ycmd uses `filetypes` to identify the "language" of a given buffer. These
filetype values are strictly the values understood by Vim. Please see the
YCM README.md for the list of filetypes recognized by ycmd for semantic
completion.
version: 0.3.0
externalDocs:
description: ycmd GitHub page
url: https://github.com/Valloric/ycmd
definitions:
YesNo:
type: boolean
description: "Result of the query: `true` if yes, `false` otherwise."
AlwaysYes:
type: boolean
description: "`true` is always returned, unless there is an error."
LineNumber:
type: integer
description: 1-based line number.
ColumnNumber:
type: integer
description: 1-based column byte offset within the line.
FilePath:
type: string
description: |-
Absolute path to the file in the filesystem. If the file does
not yet exist (for example, a new file), then the value should be an
arbitrary unique string.
CompleterTarget:
type: string
description: |-
The completer implementation for which the command is intended. Typically,
this is set to `filetype_default`, but may also take any of the following
values:
- `filetype_default`
Use the semantic completer associated with the filetype of the current
buffer. This is the default when a target is not supplied.
- `identifier`
Use the identifier completer.
- Any filetype
Use the completer associated with the supplied filetype.
WorkingDirectory:
type: string
description: |-
Absolute path to the filesystem working directory of the client. This is
used by completer engines to determine things like the project root
for the file being modified, amongst other things.
ExtraConfData:
type: object
description: |-
A dictionary passed to the `Settings( **kwargs )` function of the
`.ycm_extra_conf.py` file under the `client_data` key of `kwargs`. This
optional field should be used to give users a way to customize the
`.ycm_extra_conf.py` file with their own set of options.
FileData:
type: object
description: |-
Contents and details of a dirty buffer.
required:
- filetypes
- contents
properties:
filetypes:
type: array
items:
type: string
contents:
type: string
description: The entire contents of the buffer encoded as UTF-8.
FileDataMap:
type: object
description: |-
An object mapping whose keys are the absolute paths to the
files and whose values are data relating unsaved buffers.
An unsaved buffer is any file that is opened in the editor and has been
changed without saving the contents to disk.
The file referred to in the request `filepath` entry must _always_ be
included. For most requests this is the user's current buffer, but may
be any buffer (e.g. in the case of closing a buffer which is not current).
When a file is closed in the editor, a `BufferUnload` event should be sent
and the file should not be included in further `FileDataMap` entries
until (or unless) it is opened and changed again.
additionalProperties:
$ref: "#/definitions/FileData"
# Due to the way the API combines keys at the top level, we are not able to
# compose this item per-request. So this definition must be copy-pasted for
# some requests.
SimpleRequest:
type: object
required:
- line_num
- column_num
- filepath
- file_data
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
completer_target:
$ref: "#/definitions/CompleterTarget"
working_dir:
$ref: "#/definitions/WorkingDirectory"
extra_conf_data:
$ref: "#/definitions/ExtraConfData"
Exception:
type: object
description: JSON-encoded representation of a Python Exception object.
# We don't document the contents of this object, as it is defined in the
# Python documentation.
additionalProperties: true
ExceptionResponse:
type: object
description: |-
The server raised an exception processing the request. This response is
often returned when the server is unable to perform the requested action,
not due to a bug or other error, but because it is not possible to do so.
For example, it is common for an exception response to be returned when
requesting "GoToDefinition" on an identifier for which the semantic,
engine is unable to find such a definition.
properties:
exception:
$ref: "#/definitions/Exception"
message:
type: string
description: |-
The exception message. Typically a single line and suitable for
display to a user.
traceback:
type: string
description: |-
A detailed report of the ycmd call stack at the point the exception
was thrown. It is typically not required to display this to a user,
as ycmd will print all exceptions to its log file (standard error).
Location:
type: object
description: |-
A contiguous range of bytes in a source buffer starting at `start` and
finishing at `end`. The range is (effectively) exclusive. That is if start
points to (10,1) and end points to (10,3), then the length of the range
is 2 characters.
required:
- line_num
- column_num
- filepath
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
Range:
type: object
description: A contiguous range of bytes in a source buffer.
required:
- start
- end
properties:
start:
$ref: "#/definitions/Location"
end:
$ref: "#/definitions/Location"
DiagnosticData:
type: object
description: |-
- `location`
The source location where the diagnostic applies. This is typically
(but not always) the start of `location_extent`.
- `location_extent`
The source range to which the diagnostic applies. This differs from
the `location` in that it refers to the whole range. Typically this is
used to underline, or otherwise render as "error" the source code
which caused the diagnostic.
required:
- ranges
- location
- location_extent
- text
- kind
properties:
ranges:
type: array
description: |-
List of ranges to which this diagnostic applies. These ranges
typically identify the source locations which should be
"highlighted" as incorrect.
items:
$ref: "#/definitions/Range"
location:
$ref: "#/definitions/Location"
location_extent:
$ref: "#/definitions/Range"
text:
type: string
description: The diagnostic text (e.g. error message)
kind:
type: string
enum:
- WARNING
- ERROR
- INFORMATION
- HINT
description: |-
The type of diagnostic being reported. Typically semantic engines will
differentiate between warnings and fatal errors. Informational and
hint messages should be treated as warnings where the client does not
differentiate.
fixit_available:
type: boolean
description: |-
If set to true, indicates that a quick fix action (FixIt) is
available for this diagnostic. Typically this is used to indicate to
the user that the `FixIt` subcommand is available.
DiagnosticResponse:
type: array
items:
$ref: "#/definitions/DiagnosticData"
SubcommandResponse:
type: object
properties:
fixits:
type: array
description: |-
If present, this is a *FixIt* or *Refactor* response and the
value of this property is a list of potential changes to
buffers to apply the quick fix or refactoring operation.
An empty `fixits` list means that no FixIt or refactoring
was available. If multiple entries are supplied, the user is
prompted to select which one to apply.
items:
$ref: "#/definitions/FixIt"
minItems: 0
message:
type: string
description: |-
If present, this is a *simple display message* and the value
of this property is the message to display.
detailed_info:
type: string
description: |-
If present, this is a *detailed information* response and
the value of this property is the multi-line information
to display as unformatted plain text.
filepath:
type: string
description: |-
If present, this is a single *GoTo response* and this value
contains the absolute path of the buffer containing the
target location (identified in `line_num` and `column_num`).
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
UnresolvedFixIt:
type: object
required:
- resolve
properties:
resolve:
type: boolean
description: |-
Indicates whether the fixit requires additional processing.
FixIt:
type: object
required:
- location
- resolve
- chunks
properties:
text:
type: string
description: |-
The diagnostic text or a description of the modification to be made.
This is the text displayed to the user when selecting from multiple
available FixIts.
location:
$ref: "#/definitions/Location"
resolve:
type: boolean
description: |-
Indicates whether the fixit requires additional processing.
kind:
type: string
description: |-
FixIt kind is meant to suggest what sort of fixit this is. Clients
are free to ignore this property or use it to decide whether to
automatically apply the fixit. SUpported values are those of LSP.
Search for `namespace CodeActionKind` in the following link
https://microsoft.github.io/language-server-protocol/specifications/specification-3-15/#textDocument_codeAction
chunks:
type: array
description: |-
A list of ranges and replacements which must be applied to source
files. *NOTE*: The source ranges may span arbitrary files and the
sequence of `chunks` is not defined.
items:
type: object
required:
- replacement_text
- range
properties:
replacement_text:
type: string
description: |-
The text with which to replace the range identified by `range`.
range:
$ref: "#/definitions/Range"
Candidate:
type: object
properties:
insertion_text:
type: string
description: |-
The word to insert when selecting the completion.
Equivalent of the Vim `complete-items` entry: `word`.
menu_text:
type: string
description: |-
The word to display as the suggestion to the user. If not
supplied, `insertion_text` is displayed to the user.
Equivalent of the Vim `complete-items` entry: `abbr`.
extra_menu_info:
type: string
description: |-
Additional information to display about the suggestion within
the completion menu (or equivalent). Typically this is the
signature/declaration of the item being suggested, or some
additional free-text qualifiers (such as `[File]` etc.). These
are a single line and typically short. For more detailed
information, such as usage and docs, see `detailed_info`.
Equivalent of the Vim `complete-items` entry: `menu`.
detailed_info:
type: string
description: |-
Additional information, such as the full signature and method
documentation, suitable for display in a preview window or
tooltip.
Equivalent of the Vim `complete-items` entry: `info`.
kind:
type: string
description: |-
An indicator of the type of suggestion. Only the first character
of `kind` should be displayed.
Equivalent of the Vim `complete-items` entry: `kind`.
extra_data:
type: object
description: |-
Completer-specific additional information.
properties:
doc_string:
type: string
description: |-
Additional documentation/information to be displayed
alongside (after) information in `detailed_info`.
fixits:
type: array
description: |-
Any editional edits to apply when selecting this completion
items:
$ref: "#/definitions/FixIt"
resolve:
type: number
description: |-
Identifier used to resolve this completion item using
/resolve_completion. If not supplied, the item is already
fully resolved.
CompletionResponse:
type: object
required:
- completions
- completion_start_column
properties:
completions:
type: array
description: List of completion suggestions.
items:
$ref: "#/definitions/Candidate"
completion_start_column:
type: integer
description: |-
1-based byte index of the column from which the completion should be
applied. This is the column in which the words suggested in
`completions` should be placed.
errors:
type: array
description: Any errors reported by the semantic completion engine.
items:
$ref: "#/definitions/ExceptionResponse"
ResolveCompletionResponse:
type: object
required:
- completion
- errors
properties:
completion:
$ref: "#/definitions/Candidate"
errors:
type: array
description: Any errors reported by the semantic completion engine.
items:
$ref: "#/definitions/ExceptionResponse"
ItemData:
type: object
required:
- key
- value
properties:
key:
type: string
value:
type: string
ServerData:
type: object
required:
- name
- is_running
- executable
- address
- port
- pid
- logfiles
- extras
properties:
name:
type: string
description: The server name.
is_running:
type: boolean
description: |-
`true` if the server is running, `false` otherwise.
executable:
type: string
description: The executable path used to start the server.
address:
type: string
description: |-
The address on which the server is listening. `null` if not
applicable.
port:
type: integer
description: |-
The port on which the server is listening. `null` if not applicable.
pid:
type: integer
description: |-
The process identifier of the server. `null` if the server is not
running.
logfiles:
type: array
description: A list of logging files used by the server.
items:
type: string
description: A logging file path.
extras:
type: array
items:
$ref: "#/definitions/ItemData"
DebugInfoResponse:
type: object
required:
- name
- servers
- items
properties:
name:
type: string
description: The completer name.
servers:
type: array
description: A list of servers used by the completer.
items:
$ref: "#/definitions/ServerData"
items:
type: array
description: Additional debugging information.
items:
$ref: "#/definitions/ItemData"
MessagePollResponse:
type: boolean
description: |-
When `true` is returned, the request timed out (meaning no
messages were returned in the poll period). Clients should
send another `receive_messages` request immediately.
When `false` is returned, the server determined that message
polling should abort for the current file type context. Clients
should not re-send this request until the filetype being edited
changes or the server is restarted.
MessageList:
type: array
description: |-
A list of messages in the sequence they should be handled.
The type of message in each item is determined by the property name:
- An object with a property `message` is a *simple display message* where
the property value is the message.
- An object with a property `diagnostics` contains diagnostics for a
project file. The value of the property is described below.
items:
$ref: '#/definitions/Message'
Message:
type: object
description:
An object containing a single asynchronous message.
It is either a `SimpleDisplayMessage` or a `DiagnosticsMessage`
properties:
message:
$ref: '#/definitions/SimpleDisplayMessage'
description: If present, this object is a `SimpleDisplayMessage`
diagnostics:
$ref: '#/definitions/DiagnosticsMessage'
description: If present, this object is a `DiagnosticsMessage`
SimpleDisplayMessage:
type: string
description: |-
A message for display to the user. Note: the message should be displayed
discreetly (such as in a status bar) and should not block the user or
interrupt them.
DiagnosticsMessage:
type: object
description: |-
Diagnostics for a particular file. Note: diagnostics may be supplied for
any arbitrary file. The client is responsible for displaying the
diagnostics in an appropriate manner. The server supplies an empty set of
diagnostics to clear the diagnostics for a particular file.
required:
- filepath
- diagnostics
properties:
filpath:
$ref: '#/definitions/FilePath'
diagnostics:
type: array
items:
$ref: "#/definitions/DiagnosticData"
paths:
/event_notification:
post:
summary: Notify the server of various client events.
description: |-
The server needs to react to a number of client events in order to
provide things like diagnostics and to handle downstream server states
etc. The client must inform the server of the following events,
populating the event name in the `event_name` property:
- `FileReadyToParse`
Call when a new buffer is opened or after the user has
stopped typing for some time, or at any other time when the client
believes that it is worthwhile reparsing the current file and
updating semantic engines' ASTs and reporting things like updated
diagnostics.
- `BufferUnload`
Call when the user closes a buffer that was previously known to be
open. Closing buffers is important to limit resource usage.
- `BufferVisit` (optional)
Call when the user focuses on a buffer that is already known.
*Note*: The `ultisnips_snippets` property is optional when firing
calling this event. Otherwise it is ignored.
- `InsertLeave` (optional)
For modal editors, call when exiting insert mode. It is equivalent
to `CurrentIdentifierFinished`.
- `CurrentIdentifierFinished` (optional)
Call when the user finishes typing what appears to the client to be
an identifier.
- `FileSave`
Call when the user writes to a file on disk. (optional)
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The notification data. The line and column are typically not used,
but the `filepath` and file data properties are used to perform
semantic analysis (e.g. in the `FileReadyToParse` handler).
required: true
schema:
type: object
required:
- line_num
- column_num
- filepath
- file_data
- event_name
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
completer_target:
$ref: "#/definitions/CompleterTarget"
working_dir:
$ref: "#/definitions/WorkingDirectory"
extra_conf_data:
$ref: "#/definitions/ExtraConfData"
event_name:
type: string
enum:
- FileReadyToParse
- BufferUnload
- BufferVisit
- InsertLeave
- CurrentIdentifierFinished
description: The event that occurred.
ultisnips_snippets:
type: object
description: |-
*Optional when `event_name` is BufferVisit*
Supplies the ultisips snippets known for the current
filetypes. Can be used to supply any other type of additional
completion suggestions generated by the client.
required:
- trigger
- description
properties:
trigger:
type: string
description: |-
The text to insert in order to trigger the snippet. When
supplying non-ultisnips suggestions, this is the text
to be inserted.
description:
type: string
description: |-
Additional text to display in the completion menu, such
as a summary of the snippet to be inserted.
example:
line_num: 10
column_num: 20
filepath: "/home/test/dev/test.js"
file_data:
"/home/test/dev/test.cc":
filetypes: [ 'cpp' ]
contents: "<file contents>"
event_name: "FileReadyToParse"
responses:
200:
description: Optional set of diagnostics for the current buffer.
schema:
$ref: "#/definitions/DiagnosticResponse"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/run_completer_command:
post:
summary: Run a semantic completer subcommand.
description: |-
Semantic completers offer additional engine-specific commands, known
as completer subcommands. This endpoint requests a specific command to
be executed. Typically the "default" semantic completer for the current
filetype is used, but it is possible to force the use of a particular
completer, using the `completer_target` property.
The command to execute is passed as a list of arguments, the first of
which is the command name followed by any command- and
completer-specific additional arguments. This "command line" is passed
in the `command_arguments` property.
The list of available subcommands for a particular semantic completer
can be queried using the `/defined_subcommands` endpoint.
Subcommands may return one of a number of actions, depending on the
type of command. The following types of response are returned:
- A *simple display message* response. This is identified where the
type of the response is scalar (i.e. boolean, number, string) or the
type of the response is an object with a `message` property. These
messages are typically only a single line and can be displayed in
a message-box or similarly echoed in a status bar or equivalent.
- A *FixIt* response. This is identified where the type of the response
is an object with a property named `fixits`.
- A *detailed information* response. This is identified where the type
of the response is an object with a `detailed_info` property. These
messages are typically multiple lines (such as the documentation and
signature for a method) and are best displayed in a panel or preview
area (or equivalent).
- A *GoTo* response. This is identified where the response type cannot
be determined by any of the above methods. A GoTo response may contain
either a single location (e.g. for `GoToDeclaration`), or a list of
possible locations for the user to chose from (such as in a
`GoToReferences` subcommand).
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
type: object
required:
- line_num
- column_num
- filepath
- file_data
- command_arguments
- options
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
completer_target:
$ref: "#/definitions/CompleterTarget"
working_dir:
$ref: "#/definitions/WorkingDirectory"
extra_conf_data:
$ref: "#/definitions/ExtraConfData"
command_arguments:
type: array
description: |-
The command line to execute as a list of arguments. The first
such argument is the subcommand to execute (for example:
`GoTo`).
items:
type: string
range:
description: |-
The range to which the command is applied (only used by the
*Format* command).
$ref: "#/definitions/Range"
options:
type: object
description: |-
A set of editor-related options for the current buffer (only
used by the *Format* command).
required:
- tab_size
- insert_spaces
properties:
tab_size:
description: The size of a tabulation in spaces.
type: integer
insert_spaces:
description: Use spaces to represent tabulations.
type: boolean
example:
line_num: 10
column_num: 20
filepath: "/home/test/dev/test.js"
file_data:
"/home/test/dev/test.js":
filetypes: [ 'javascript' ]
contents: "<file contents>"
completer_target: "filetype_default"
command_arguments: [ 'RefactorRename', 'Testing' ]
options:
tab_size: 4
insert_spaces: true
responses:
200:
description: |-
Optional action or display text in response to the request.
*NOTE*: If the type of the response is not an object or list,
then the response is a *simple display message*.
*NOTE*: If the type of the response is a list, then the response is
a GoTo list (e.g. quick-fix list or equivalent) and the
items in the list are of type `GoToLocations`
(see definitions).
schema:
$ref: "#/definitions/SubcommandResponse"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/completions:
post:
summary: Get completion suggestions for the current file context.
description: |-
Returns the autocompletion suggestions for the current cursor
position. Typically, the server determines whether or not to use
semantic completion or general (i.e. identifier-based) completion
based on the language (filetype) and the context. Clients can force
the use of semantic completion by setting the `force_semantic`
property to `true`.
Note that if `force_semantic` is not set to `true` and the completion
engine returns an error, the server still tries to fall back to
general completion, so this endpoint will typically always return
successfully. Any semantic completer error raised is included in the
response to be dealt with by the client.
When `force_semantic` is `true`, any error returned by the semantic
engine is returned via a 500 response.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: The list of completion suggestions.
schema:
$ref: "#/definitions/CompletionResponse"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/resolve_completion:
post:
summary: Resolve detailed_info for a completion item
description: |-
Given the `resolve` ID for a completion item, returns the item with
additional data filled in.
Note, the supplied `request_data` must match exactly the `request_data`
for the corresponding completion request, except with the `resolve` key
filled in with the `resolve` ID from the completion item's `extra_data`.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
type: object
required:
- line_num
- column_num
- filepath
- file_data
- resolve
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
completer_target:
$ref: "#/definitions/CompleterTarget"
working_dir:
$ref: "#/definitions/WorkingDirectory"
extra_conf_data:
$ref: "#/definitions/ExtraConfData"
resolve:
description: |-
The 'resolve' key from the 'extra_data' in the completion item
to resolve.
responses:
200:
description: The list of completion suggestions.
schema:
$ref: "#/definitions/ResolveCompletionResponse"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/signature_help_available:
get:
summary: Is /signature_help supported for some filetype
description: |-
Since /signature_help can be expensive, clients can query ycmd with
/signature_help_available and then stop sending /signature_help if there
is no support for that filetype.
If the response is PENDING, the client should make another
/signature_help_available request later.
produces:
- application/json
parameters:
- name: subserver
in: query
description: |-
Subserver filetype for which the request is made. If a subserver
supports multiple filetypes, the parameter may hold any one of them.
required: true
type: string
responses:
200:
description: Signature help support info.
schema:
type: object
required:
- available
properties:
available:
type: string
enum:
- YES
- NO
- PENDING
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/signature_help:
post:
summary: Get signature help (argument hints) for current file context.
description: |-
Returns a list of method signatures relevant to the current cursor
position, along with an indication of which signature and argument
are 'active'.
Only returned by semantic engines.
Signatures are actually queried immediately after a trigger character.
The result of this is that the client and server collude on remembering
the current "trigger" state for signature help. This trades off
some complexity in clients for significant performance benefits in the
general case.
The client is responsible for maintaining the state of any displayed
signature help popup, and is responsible for hiding it when this request
returns an empty set of signatures.
That is, when this request returns a non-empty list of signatures,
signature help is considered "triggered' and the client must record this
and return it in the 'signature_help_state' request field
(value `ACTIVE`). The client continues to request signature help on
new input and should update its state to `INACTIVE` whenever this
request returns an empty list of signatures.
If any errors are reported by the semantic engine, they are reported in
the `errors` key in the response.
The first signature and the first argument are both 0.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
type: object
required:
- line_num
- column_num
- filepath
- file_data
properties:
line_num:
$ref: "#/definitions/LineNumber"
column_num:
$ref: "#/definitions/ColumnNumber"
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
completer_target:
$ref: "#/definitions/CompleterTarget"
extra_conf_data:
$ref: "#/definitions/ExtraConfData"
signature_help_state:
type: string
enum:
- ACTIVE
- INACTIVE
description: |-
The current state of the signature help triggering. After
signatures are returned for the first time (triggered), the
client sends further requests with `signature_help_state` set
to `ACTIVE` until the request returns no signatures.
responses:
200:
description: Signature info.
schema:
type: object
required:
- signature_help
- errors
properties:
errors:
type: array
description: errors reported by the semantic completion engine.
items:
$ref: "#/definitions/ExceptionResponse"
signature_help:
type: object
required:
- activeSignature
- activeParameter
- signatures
properties:
activeSignature:
type: number
description: The active signature. The first is 0.
activeParameter:
type: number
description: The active parameter. The first is 0.
signatures:
type: array
description: The list of signatures
items:
type: object
properties:
label:
description: |
The full signature text, including parameters
type: string
parameters:
description: List of parameters
type: array
items:
type: object
properties:
label:
description: |
The array of offsets representing an inclusive
start and exclusive end within the parameter's
containing signature label.
Offsets are byte offsets into the UTF8 encoded
string 'label'
type: array
maxItems: 2
minItems: 2
items:
type: integer
required:
- label
- parameters
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/filter_and_sort_candidates:
post:
summary: Filter and sort a set of candidates using ycmd's fuzzy matching.
description: |-
For filetypes not natively supported by ycmd, clients can often
determine a set of suitable candidate completion suggestions by other
means. In Vim this is typically from the `omnifunc` and other clients
will have equivalents.
This endpoint allows clients to use ycmd's powerful filtering and
ranking capabilities (including longest-common-subsequence and
word-boundary-character ranking) on arbitrary sets of identifiers.
*NOTE:* This API is primarily intended for use when subclassing the
`Completer` class outside of ycmd which is a very niche case,
specific to the `OmniCompleter` in the Vim client. It is not
expected that this API be used elsewhere.
produces:
- application/json
parameters:
- name: request_data
in: body
required: true
description: |-
The set of candidates to sort of the query parameters.
*NOTE:* This `request_data` object is different from most other
ycmd requests as it does not contain buffer data or
cursor locations.
schema:
type: object
properties:
candidates:
type: array
description: The candidates to filter and sort
items:
$ref: "#/definitions/Candidate"
sort_property:
type: string
enum:
- word
- insertion_text
description: |-
Typically set to `insertion_text`, but can be set to `word` when
the candidates are in the form of a simple list of words. In
the latter case, `candidates` must be a list of strings.
query:
type: string
description: |-
The text the user has typed so far for the current identifier.
This is to filter against the suggestions in `candidates`.
responses:
200:
description: The filtered list of candidated
schema:
type: array
items:
$ref: "#/definitions/Candidate"
500:
description: An error occurred
schema:
$ref: "#/definitions/ExceptionResponse"
/healthy:
get:
summary: Check if the server is healthy.
description: |-
Return `true` if the server is healthy, `false` otherwise. The client
should use this endpoint to keep the server alive.
# We don't document the subserver query parameter as it is only for
# testing.
produces:
- application/json
responses:
200:
description: Server is healthy.
schema:
$ref: "#/definitions/AlwaysYes"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
# We don't document the /ready handler as it is only for testing.
/semantic_completer_available:
post:
summary: Determine if semantic completion is available for current buffer.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: Whether or not semantic completion is available.
schema:
$ref: "#/definitions/YesNo"
500:
description: An error occurred
schema:
$ref: "#/definitions/ExceptionResponse"
/defined_subcommands:
post:
summary: Get the list of subcommands which are available for a completer.
description: |-
Returns the list of completer subcommands for a given completer.
See also: `/run_completer_command`
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: The list of available subcommands.
schema:
type: array
items:
type: string
500:
description: An error occurred
schema:
$ref: "#/definitions/ExceptionResponse"
/detailed_diagnostic:
post:
summary: Get additional information about diagnostic under cursor.
description: |-
Where available returns addition information about the diagnostic, such
as the full text of the compile error, suggestions, etc.
Typically, details are returned for the diagnostic nearest to the
current cursor position.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: The detailed diagnostic
schema:
type: object
required:
- message
properties:
message:
type: string
500:
description: An error occurred, or no diagnostic was available
schema:
$ref: "#/definitions/ExceptionResponse"
/load_extra_conf_file:
post:
summary: Forcefully load the config for the current buffer.
description: |-
By default, ycmd will not load `.ycm_extra_conf.py` files for security
reasons and instead raises an exception the first time it requires
loading.
In the case that exception is raised, the client should call this
API endpoint after confirming with the user that it is safe to load
the reported `.ycm_extra_conf.py` file.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: Configuration file loaded.
schema:
$ref: "#/definitions/AlwaysYes"
500:
description: An error occurred loading the configuration file.
schema:
$ref: "#/definitions/ExceptionResponse"
/ignore_extra_conf_file:
post:
summary: Forcefully ignore the config for the current buffer.
description: |-
As opposed to `/load_extra_conf_file`, this API endpoint must be called
when the user declines to load the associated `.ycm_extra_conf.py` file.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: Configuration file ignored.
schema:
$ref: "#/definitions/AlwaysYes"
500:
description: An error occurred ignoring the configuration file.
schema:
$ref: "#/definitions/ExceptionResponse"
/debug_info:
post:
summary: Return server and semantic engine debug information.
description: |-
Returns debugging information about the server itself and the
semantic completer for the current buffer (if there is one).
This data includes things like the versions of linked-in libraries,
log file locations, etc.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: A dictionary of debugging information.
schema:
type: object
properties:
python:
type: object
description: |-
Debugging information on the Python interpreter in which the
server is running.
properties:
executable:
type: string
description: Python interpreter path.
version:
type: string
description: Python interpreter version.
clang:
type: object
description: Debugging information on Clang.
properties:
has_support:
type: boolean
description: |-
`true` if the ycmd server was built with Clang support,
`false` otherwise.
version:
type: string
description: |-
if `has_support` is `true`, return the version of Clang.
Otherwise, return `null`.
extra_conf:
type: object
description: |-
Debugging information on the extra configuration file for the
current buffer.
properties:
path:
type: string
description: |-
Path of the found extra configuration file, loaded or not.
is_loaded:
type: boolean
description: |-
`true` if the extra configuration file is loaded, `false`
otherwise.
completer:
description: |-
Contains debugging information on the completer for the given
filetypes. `null` if no completer is available.
$ref: "#/definitions/DebugInfoResponse"
examples:
application/json:
python:
executable: "/path/to/python/interpreter"
version: "python version"
clang:
has_support: true
version: "clang version"
extra_conf:
is_loaded: false
path: "/path/to/extra/conf"
completer:
name: "completer name"
servers:
- name: "server name"
is_running: true
executable: "/path/to/executable"
address: "127.0.0.1"
port: 1234
pid: 12345
logfiles:
- "/path/to/stdout/logfile"
- "/path/to/stderr/logfile"
extras:
- description: "description"
- value: "value"
items:
- description: "description"
value: "value"
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/receive_messages:
post:
summary: Long poll for asynchronous server messages.
description: |-
Return asynchronous messages from the server. This request is
used by clients in a "long poll" style, and does not return until
either:
- A message (or messages) becomes available, in which case a list of
messages is returned, or
- a timeout occurs (after 60s), in which case `true` is returned and
the client should re-send this request, or
- for some reason the server determined that the client should stop
sending `receive_messages` requests, in which case `false` is
returned, and the client should only send the request again when
something substantial changes such as a new file type is opened, or
the completer server is manually restarted.
The following types of event are delivered asynchronously for certain
filetypes:
- Status messages to be displayed unobtrusively to the user.
- Diagnostics (for Java only).
This message is optional. Clients do not require to implement this
method, but it is strongly recommended for certain languages to offer
the best user experience.
produces:
- application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
$ref: "#/definitions/SimpleRequest"
responses:
200:
description: |-
Messages are ready, the request timed out, or the request
is not supported and should not be retried.
The response may be **one of** `MessagePollResponse` or
`MessagesList`.
schema:
allOf:
- $ref: '#/definitions/MessagePollResponse'
- $ref: '#/definitions/MessageList'
examples:
application/json:
- message: 'Initializing: 19% complete'
- message: 'Initializing: Done.'
- diagonostics:
filepath: '/file'
diagnostics:
- ranges:
- start: { line_num: 10, column_num: 11, filepath: '/file' }
end: { line_num: 10, column_num: 20, filepath: '/file' }
location: { line_num: 10, column_num: 11, filepath: '/file' }
location_extent:
start: { line_num: 10, column_num: 11, filepath: '/file' }
end: { line_num: 10, column_num: 11, filepath: '/file' }
text: Very naughty code!
kind: WARNING
fixit_available: false
- ranges:
- start: { line_num: 19, column_num: 11, filepath: '/file' }
end: { line_num: 19, column_num: 20, filepath: '/file' }
location: { line_num: 19, column_num: 11, filepath: '/file' }
location_extent:
start: { line_num: 19, column_num: 11, filepath: '/file' }
end: { line_num: 19, column_num: 11, filepath: '/file' }
text: Very dangerous code!
kind: ERROR
fixit_available: true
500:
description: An error occurred.
schema:
$ref: "#/definitions/ExceptionResponse"
/resolve_fixit:
post:
summary: Resolve an incomplete FixIt.
description: |-
Resolves an incomplete fixit, indicated by `'resolve'` fixit property.
Some completers return incomplete fixits in order to avoid blocking on
expensive fixit calculations.
When a client wishes to resolve a fixit, the entire `FixIt` object
should be sent in the `fixit` property.
If a client tries to resolve an already resolved fixit, the same fixit
is returned in a SubcommandResponse.
produces:
application/json
parameters:
- name: request_data
in: body
description: |-
The context data, including the current cursor position, and details
of dirty buffers.
required: true
schema:
type: object
required:
- filepath
- file_data
- fixit
properties:
filepath:
$ref: "#/definitions/FilePath"
file_data:
$ref: "#/definitions/FileDataMap"
fixit:
$ref: "#/definitions/FixIt"
example:
filepath: "/home/test/dev/test.c"
file_data:
"/home/test/dev/test.c":
filetypes: [ 'c' ]
contents: "<file contents>"
fixit:
$ref: "#/definitions/UnresolvedFixIt"
responses:
200:
description: |-
The fixit has been resolved and a FixIt response is returned.
schema:
$ref: "#/definitions/SubcommandResponse"
500:
description: An error occurred
schema:
$ref: "#/definitions/ExceptionResponse"
|