Commit Graph

1939 Commits

Author SHA1 Message Date
Homu
3bed9f2570 Auto merge of #1888 - jwilm:rust-lang-support, r=Valloric
Add support for the Rust programming language

Support for the Rust programming language is added using ycmd's racerd completer. This PR contains documentation for using the Rust completer and an update to the ycmd submodule.

## TODO
- [x] Update ycmd submodule once Valloric/ycmd#268 lands

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1888)
<!-- Reviewable:end -->
2016-01-09 12:31:43 +09:00
Joe Wilm
210db41a42 fixup! Update ycmd 2016-01-08 07:49:56 -08:00
Joe Wilm
0a4bd8ddf2 Fix Windows install.py invocations in README.md 2016-01-08 07:28:49 -08:00
Joe Wilm
9494b76bc2 Update ycmd 2016-01-07 09:21:35 -08:00
Joe Wilm
a74a4cbd7a Add support for the Rust programming language 2016-01-07 08:52:15 -08:00
Homu
4168a829ac Auto merge of #1876 - puremourning:fix-goto-references, r=micbou
[READY] Fix GoTo lists arriving at the wrong column.

## Problem

When a `GoTo` command returns a list of destinations, such as declarations and definitions in Python and references in JavaScript, we pop the Vim quick fix list with a list of destinations. however, we always jump to the character before the actual declaration/definition.

## Resolution

Vim's QuickFix lists require 1-based columns, which is what is returned from ycmd's commands, so don't subtract 1 from the column number.

As noted in the comments, the Vim documentation for `setqflist` is somewhat vague about this "byte offset", but it is confirmed to mean "1-based column number" both in testing and in `:help getqflist`.

## Manual testing

Tested this with the Tern completer (`:YcmCompleter GoToReferences`) and Jedi completer (`:YcmCompleter GoToDeclaration`). For the Jedi completer, use something like:

```python
x = 1
if False:
  x = 2
else:
  x = 3

print( str(x) )
```

Then `:YcmCompleter GoToDeclaration` on `x`. This returns a list, which pops up the quick fix window.

*Previous behaviour*

Previously, the jump would go to the character before the actual declaration (i.e. the `<space>` before `x` in each line)

## Automated testing

Just some simple execution of the changed code, proving that we don't take 1 from the column.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1876)
<!-- Reviewable:end -->
2016-01-05 08:22:06 +09:00
Ben Jackson
134b06b65e Fix GoTo lists arriving at the wrong column.
Vim's QuickFix lists require 1-based columns, which is what is returned
from ycmd's commands.

 As noted in the comments, the Vim documentation for setqflist is
somewhat vague about this "byte offset", but it is confirmed to mean
"1-based column number" both in testing and in :help getqflist.
2016-01-04 23:04:13 +00:00
micbou
7fda494026 Add quotes in notifications
Add quotes for Vim commands and options in notifications.
2016-01-03 12:13:00 +01:00
micbou
da095cb93b Update notifications when ycmd server crashed
Tell the user to run the YcmToggleLogs command if the server crashed.
2016-01-02 21:16:00 +01:00
Homu
07f4402f49 Auto merge of #1770 - vheon:fix-defer-omnifunc, r=Valloric
Defer setting the omnifunc only the first time

This basically is a return to the older approach where everything is done on OnBufferVisit. This way we just defer the first time.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1770)
<!-- Reviewable:end -->
2016-01-01 04:14:58 +09:00
Andrea Cedraro
ad4091635e Add comment expaning why we defer setting the omnifunc 2015-12-31 00:12:38 +01:00
Andrea Cedraro
b4beed4939 Defer setting the omnifunc only the first time
Fix #1769
2015-12-30 14:41:38 +01:00
Homu
f4c63d7b4b Auto merge of #1861 - Anzumana:master, r=Valloric
fixed readme path third-party with third_party

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1861)
<!-- Reviewable:end -->
2015-12-28 10:20:10 +09:00
Anzumana
fcf13fe148 fixed readme path third-party with third_party 2015-12-28 01:51:57 +01:00
Homu
85a5ea0a6d Auto merge of #1860 - micbou:empty-completed-item, r=Valloric
[READY] Fix traceback when v:completed_item is empty

### Problem

A traceback is raised in Vim when completing in a C♯ file while the ycmd server crashed:
```
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
Traceback (most recent call last):
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "<string>", line 1, in <module>
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 305, in OnCompleteDone
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
    action(self)
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 102, in <lambda>
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
    'cs': lambda( self ): self._OnCompleteDone_Csharp()
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 428, in _OnCompleteDone_Csharp
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:

Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 327, in GetCompletionsUserMayHaveCompleted
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
    if self._HasCompletionsThatCouldBeCompletedWithMoreText( completions ):
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
  File "C:\\Users\\micbou\\.vim\\bundle\\YouCompleteMe\\autoload\../python\ycm\youcompleteme.py", line 393, in _HasCompletionsThatCouldBeCompletedWithMoreText
_NewerVim
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
    if not completed_item:
Error detected while processing function <SNR>27_OnCompleteDone:
line    1:
KeyError: 'word'
```
It happens because the Vim variable `v:completed_item` is empty. From Vim documentation on `v:completed_item`:

> Dictionary containing the complete-items for the most 	recently completed word after CompleteDone.  **The Dictionary is empty if the completion failed**.

### Solution

Check if `v:completed_item` is empty before accessing its `word` key.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1860)
<!-- Reviewable:end -->
2015-12-28 03:43:31 +09:00
micbou
f015d518a3 Fix traceback when v:completed_item is empty
Check if the Vim variable v:completed_item is not empty before
accessing one of its keys. Prevent a traceback when the ycmd server
crashed.
2015-12-27 18:46:05 +01:00
Homu
7b6199e06b Auto merge of #1855 - ymattw:capture-build-error, r=Valloric
Use check_call to capture error from build process

Without this install.py always exits 0 and no way to tell vim-plug its installation actually failed.

Before:

```
$ ./install.py
...

-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build.Vu_ej5/CMakeFiles/CMakeOutput.log".
See also "/tmp/ycm_build.Vu_ej5/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 312, in <module>
    Main()
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 303, in Main
    BuildYcmdLibs( args )
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 248, in BuildYcmdLibs
    subprocess.check_call( [ 'cmake' ] + full_cmake_args )
  File "/usr/lib64/python2.6/subprocess.py", line 505, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-G', 'Unix Makefiles', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp']' returned non-zero exit status 1

$ echo $?
0
```

After:

```
$ ./install.py
...

-- Configuring incomplete, errors occurred!
See also "/tmp/ycm_build.p6F7yK/CMakeFiles/CMakeOutput.log".
See also "/tmp/ycm_build.p6F7yK/CMakeFiles/CMakeError.log".
Traceback (most recent call last):
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 312, in <module>
    Main()
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 303, in Main
    BuildYcmdLibs( args )
  File "/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py", line 248, in BuildYcmdLibs
    subprocess.check_call( [ 'cmake' ] + full_cmake_args )
  File "/usr/lib64/python2.6/subprocess.py", line 505, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['cmake', '-G', 'Unix Makefiles', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/cpp']' returned non-zero exit status 1
Traceback (most recent call last):
  File "./install.py", line 32, in <module>
    Main()
  File "./install.py", line 21, in Main
    subprocess.check_call( [ python_binary, build_file ] + sys.argv[1:] )
  File "/usr/lib64/python2.6/subprocess.py", line 505, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['/usr/bin/python', '/root/.vim/plugged/YouCompleteMe/third_party/ycmd/build.py']' returned non-zero exit status 1

$ echo $?
1
```

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1855)
<!-- Reviewable:end -->
2015-12-26 16:14:17 +09:00
Matthew Wang
710652523f Use check_call to capture error from build process
Without this install.py always exits 0 and no way to tell vim-plug
its installation actually failed
2015-12-26 12:35:10 +08:00
Homu
414f482b1c Auto merge of #1849 - puremourning:tern-completer, r=vheon
[READY] Add JavaScript completion using Tern completer

## JavaScript completer

Adds support for native JavaScript completion using ycmd's Tern completer.

WIP because relies on #1848 to be merged first.

This PR:

- Adds functional documentation to the README.md
- Adds configuration documentation to the README.md
- Updates the vim doc inline with the above
- And, most importantly, updates `ycmd` submodule to include the Tern completer and the additional fixes.

## ycmd changes

There are quite a lot of commits going in to ycmd. Here's a summary of the PRs:
```
8ec8386 Auto merge of #283 - micbou:appveyor-python-issue, r=puremourning
d079a92 Auto merge of #280 - puremourning:tern-global-config, r=Valloric
dee9afe Auto merge of #281 - puremourning:tern-timeout-exit, r=Valloric
24f5d51 Auto merge of #279 - micbou:coverage, r=Valloric
115a51d Auto merge of #275 - d0k:reparse, r=Valloric
68edd9d Auto merge of #270 - micbou:refactor-tests, r=Valloric
1caabf5 Auto merge of #272 - puremourning:tern-completer-locking, r=Valloric
5c3823d Auto merge of #274 - micbou:coverage-exclude, r=vheon
22bacb3 Auto merge of #271 - puremourning:tests-coverage-doc, r=Valloric
```

Full list can be obtained via the following command in `third-party/ycmd`: `git log --oneline 22c8670c93b4ae9930c9cdf31ad9995c7fd057bd..8ec83866948b24591f62525f027b7aa4aac3e1ad`

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1849)
<!-- Reviewable:end -->
2015-12-25 06:53:58 +09:00
Homu
f85b8427e0 Auto merge of #1848 - puremourning:file-ready-to-parse, r=vheon
[READY] Raise warnings on FileReadyToParse for completers not supporting diagnostics

Fixes #1829

## Background

Detailed analysis is available on [the issue](https://github.com/Valloric/YouCompleteMe/issues/1829). But principally: if the filetype being edited is not a filetype suporting YCM native diagnostics, then warnings, errors, etc. (including the "unknown extra conf" warning/prompt) are not displayed after the "FileReadyToParse" `event_notification`

## Resolution

The approach is: for filetypes which do not support diagnostics, rather than ignoring all `FileReadyToParse` event responses, simply call the `Response` method, which raises the appropriate error or handles the "confirm extra-conf" behaviour. Any other data returned by the completer (such as diagnostics!), are simply ignored.

## Manual Testing

Tested with tern completer which raises an error if the `.tern-project` file is not found.
Tested with a modified tern completer with the following `OnFileReadyToParse`:

```python
  def OnFileReadyToParse( self, request_data ):
    self._WarnIfMissingTernProject()

    module = extra_conf_store.ModuleForSourceFile( request_data[ 'filepath' ] )
    if not module:
      if not self._raised_extra_conf_warning:
        self._raised_extra_conf_warning = True
        raise NoExtraConfDetected
      return

    # use module!
```

Results all as expected:

- with no `.tern-config`: tern config warning (once)
- with `.tern-config`, but no `.ycm_extra_conf`: no extra conf warning (once)
- with `.tern-config` and `.ycm_extra_conf`: confirmation prompt (once)

## Automated Testing

This was a marathon. Or a mockathon, I suppose.

Briefly:

- I wrote a `event_notification_test.py` which tests these new `YouCompleteMe` object behaviours, via a complex series of mocking
- I had to refactor the `postcomplete_tests.py` to prevent it from leaving `MagicMock` instances all over the place because this lead to the above test failing (apparently) randomly
- In order to debug the above shenanigans I updated `run_tests.py` to allow passing arguments to nosetests, like we do in `ycmd`

There are more comments in the code and on the various commit messages, explaining what's going on.

With regard to style, there is quite a lot of:

```python

@contextlib.contextmanager
def something():
  with patch(this):
    with patch(that):
      with patch(the_other):
        yield

@patch( foo )
def do_a_test( foo ):
  with something():
    do_a_thing()
    assert foo.called()
```

The reason for this relative ugliness is that there is a lot of boilerplate mocking code. Because of a number of foibles of `mock` and the versions of python we support, I found this to be the least hacky way of ensuring that everything was cleaned up and was relatively sane to read and maintain.

Explanation for the `with`-ception that is going on:

- @patch is my preferred method, but it is more difficult to comment well and doesn't work when used with `@contextlib.contextmanager`, so you have to use `with`
- multiple managers in a single `with` statement is not supported in Python 2.6
- `contextlib.nested` is deprecated and buggy (apparently)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1848)
<!-- Reviewable:end -->
2015-12-25 06:36:55 +09:00
Ben Jackson
0b07b7467d Add tests for YouCompleteMe.ValidateParseRequest
Most of the code is mocking boilerplate but it shows that the behaviour is as
defined in the comments.
2015-12-24 21:06:44 +00:00
Ben Jackson
559c76232e update vimdoc 2015-12-24 11:49:58 +00:00
Ben Jackson
702081b0ed Tidy up language.
- Fix some subordinate clause gymnastics
- Signpost the tern configuration advice better
- Signpost the link to the Tern docs better
- Sort out some bullet-list issues
2015-12-24 11:46:41 +00:00
Ben Jackson
baba751dab Correct subcommand usage. Clarify changing project usage 2015-12-23 11:21:43 +00:00
Ben Jackson
0162d4ad71 Add a FAQ entry pointing at the instructions 2015-12-23 01:17:29 +00:00
Ben Jackson
10bdde1240 Update ycmd to include tern completer 2015-12-22 23:35:41 +00:00
Ben Jackson
ba700f2f0d Update Vim doc 2015-12-22 23:35:29 +00:00
Ben Jackson
c090fda4be State that tern completer needs installation 2015-12-22 23:35:29 +00:00
Ben Jackson
636279cc58 Allow running a subset of tests
Like we do in ycmd, allow additional arguments of run_tests to be passed
directly to nosetests.

In order to maintain the existing behaviour, and not require fiddly command
lines, always run nosetests in the python directory (using the -w - working
directory) switch.
2015-12-21 19:40:51 +00:00
Ben Jackson
6029a672ee Prevent postcomplete_tests.py from leaving mock object lying around
Previously, running postcomplete_tests.py could lead to MagicMock objects being
left around within the ycm modules. This lead to random test failures in other
modules.

Further, by using mock.patch appropriately, tests withing postcomplete_tests.py
no longer rely on mocking performed by previous tests (and can be successfully
run individually)
2015-12-21 19:38:56 +00:00
Ben Jackson
861546fac0 Display errors raised by OnFileReadyToParse in non-diagnostics filetypes 2015-12-20 17:27:17 +00:00
Ben Jackson
8655490a24 Document javascript completer subcommands 2015-12-19 18:39:40 +00:00
Ben Jackson
b7bbe00344 Documentation on setting up the .tern-project file 2015-12-19 18:39:40 +00:00
Ben Jackson
570f8aae21 Add basic documentation for Tern completer 2015-12-19 17:41:09 +00:00
Homu
93c2a8644b Auto merge of #1824 - micbou:ycmd-update, r=Valloric
Update to latest ycmd

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1824)
<!-- Reviewable:end -->
2015-12-13 09:25:33 +09:00
Homu
14083d939d Auto merge of #1821 - micbou:ycm-issue-1818, r=vheon
Set buffer filetypes for UltiSnips

Currently, only `all` snippets are displayed by YCM because UltiSnips is called without setting the buffer filetypes. See issue #1818.

This is fixed by using UltiSnips methods `reset_buffer_filetypes` and `add_buffer_filetypes`.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1821)
<!-- Reviewable:end -->
2015-12-11 02:55:11 +09:00
micbou
aa73ea0175 Set buffer filetypes for UltiSnips
This fixes #1818.
2015-12-10 00:20:25 +01:00
micbou
26db1db531 Update to latest ycmd 2015-12-08 20:45:24 +01:00
Homu
cc623d43ea Auto merge of #1814 - kennykaye:error-warning-count, r=vheon
Expose functions to get error and warning counts

@Valloric I've implemented two functions which resolve #1011

The interface exposed to Vim is:

```viml
youcompleteme#GetErrorCount()
youcompleteme#GetWarningCount()
```

Below is a rough example of how these methods can be used to integrate with other plugins. In this case Lightline has been extended to show the error and warning count as red and yellow sections on the end of the status line, respectively.

![animation](https://cloud.githubusercontent.com/assets/3267574/11604073/078cb98e-9a9d-11e5-9fa3-c9b4bb6a6e82.gif)

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1814)
<!-- Reviewable:end -->
2015-12-06 06:37:39 +09:00
Kenny Kaye
0c55527a38 Included usage example for error/warning getters 2015-12-05 11:06:33 -08:00
Kenny Kaye
908fd68548 Update help doc formatting 2015-12-05 10:34:05 -08:00
Kenny Kaye
bb8490e6c7 Properly namespace vim warning/error getters 2015-12-05 09:24:15 -08:00
Kenny Kaye
163238992c Document YcmGetErrorCount and YcmGetWarningCount functions 2015-12-05 09:12:28 -08:00
Kenny Kaye
dafc36ba37 Expose functions to get error and warning counts 2015-12-04 14:45:11 -08:00
Homu
e166907e98 Auto merge of #1807 - micbou:canonical-response, r=vheon
Handle canonical response from subcommands

In continuation to PR #1805, when the ycmd server returns a canonical type (boolean, number, string, etc.), we should print it to the user.

For example, this applies to the `SolutionFile` C♯ subcommand which only returns a string (actually, this could be improved in the completer).

This also fixes a thrown exception when the response is not iterable (a number for example).

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1807)
<!-- Reviewable:end -->
2015-11-30 04:30:35 +09:00
micbou
37f3f1530e Handle scalar response from subcommands
When the ycmd server returns a scalar (boolean, number, string, etc.)
from a subcommand, print it to the user.
2015-11-29 20:03:02 +01:00
Homu
4651c2112b Auto merge of #1805 - micbou:boolean-response, r=Valloric
Handle boolean responses from ycmd subcommands

`ServerReady`, `ServerRunning`, and `ServerTerminated` C♯ subcommands could return a traceback or nothing in Vim because ycmd returns a boolean as the response of these commands.
Fix this by echoing `Yes` when the response is `True`, `No` otherwise.

Refactor the `RunPostCommandActionsIfNeeded` function to improve readability.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1805)
<!-- Reviewable:end -->
2015-11-29 02:56:14 +09:00
micbou
13aeaa37a8 Handle boolean responses from ycmd
Fix ServerReady, ServerRunning, and ServerTerminated subcommands from
C♯ completer.
2015-11-28 16:48:24 +01:00
Homu
96f0d94196 Auto merge of #1786 - ReadmeCritic:master, r=Valloric
Update README URLs based on HTTP redirects

Created with https://github.com/dkhamsing/frankenstein

### GitHub Corrected URLs
Was | Now
--- | ---
http://mxcl.github.com/homebrew/ | http://mxcl.github.io/homebrew/
https://github.com/gmarik/vundle/issues/48 | https://github.com/VundleVim/Vundle.vim/issues/48
https://github.com/nosami/OmniSharpServer | https://github.com/OmniSharp/omnisharp-server

### Other Corrected URLs
Was | Now
--- | ---
http://en.wikipedia.org/wiki/Subsequence | https://en.wikipedia.org/wiki/Subsequence
http://www.cmake.org/cmake/resources/software.html | https://cmake.org/download/

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/1786)
<!-- Reviewable:end -->
2015-11-21 14:24:12 +09:00
ReadmeCritic
6ef35bd197 Update Homebrew URL 2015-11-18 12:35:19 -08:00