Commit Graph

1744 Commits

Author SHA1 Message Date
Homu
2816559ee4 Auto merge of #1694 - puremourning:detailed-info-subcommands, r=Valloric
Allow subcommands to display information in the preview window

References
====

https://github.com/Valloric/YouCompleteMe/issues/1653

There will be some PRs coming to ycmd that will supply documentation in this format

Background
====

This adds support to YCM for displaying "detailed info" (e.g. quick-info, documentation, etc.) from a completer subcommand response. We display the info in the preview window.

Technical notes
====

Use of the preview window
----

We display the detailed info text in the preview window. Vim's preview window is designed to display actual files, not scratch data. Our approach is to open a temporary file, even though that file is never  written. This way, all of Vim's existing settings for the preview window (and people's configured mappings) just work. This is also consistent with showing the documentation in the preview
window during completion (although, Vim fixes the preview window height to 3 in that case).

Other plugins have more complicated functions for this (such as eclim), or Scratch.vim, but this approach is simple and doesn't require external dependencies or additional settings. 


 `wincmd P` etc.
---

The approach in `vimsupport.py` of jumping around with `wincmd P` and `wincmd p` was taken pretty much directly from vim's `:help preview-window` (specifically `:help CursorHold-example`), so while ugly it is apparently the 'recommended' way.

`vim` module mocking
----

I had to change the way we were mocking the `vim` module in the tests. From the commit message:

    This required fixing a sort-of-bug in which the mock'd Vim module was always
    only set once, and could not be changed outside of the module which created it.
    This meant that it wasn't easy to have arbitrary tests, because it was dependent
    on the order in which the tests execute as to whether the return from
    MockVimModule() was actually the one in use.

    The solution was to make the mock'd vim module a singleton, imported by any
    tests which require fiddling with it. This should hopefully help testing going
    forwards.

I committed this separately to help review (hopefully).
2015-09-21 12:50:20 +09:00
Ben Jackson
958d8f1eb5 Support subcommands which return detailed info
We display the detailed info text in the preview window. Vim's preview window is
designed to display actual files, not scratch data. Our approach is to open a
temporary file, even though that file is never written. This way, all of Vim's
existing settings for the preview window (and people's configured mappings) just
work. This is also consistent with showing the documentation in the preview
window during completion.

Other plugins have more complicated functions for this (such as eclim), or
Scratch.vim, but this approach is simple and doesn't require external
dependencies or additional settings.

Tests:

This required fixing a sort-of-bug in which the mock'd Vim module was always
only set once, and could not be changed outside of the module which created it.
This meant that it wasn't easy to have arbitrary tests, because it was dependent
on the order in which the tests execute as to whether the return from
MockVimModule() was actually the one in use.

The solution was to make the mock'd vim module a singleton, and use mock's
patch decorator to assign new MagicMock() instances to those methods in the vim
module which a particular test is interested in.
2015-09-20 21:30:23 +01:00
Homu
04850041b9 Auto merge of #1680 - puremourning:quick-feature-summary, r=Valloric
Add super-quick feature summary by completer

I never got time to do the larger revamp of the README.md, but I thought a super-quick summary would be useful, as I'm about to add yet-another subcommand to a bunch of completers.
2015-09-20 02:48:07 +09:00
Ben Jackson
449b6fbb9f Add super-quick feature summary by completer 2015-09-19 12:41:09 +01:00
Strahinja Val Markovic
a7bb97f100 Updating to latest ycmd 2015-09-16 18:49:33 -07:00
Homu
61a5a9b84b Auto merge of #1689 - bronzehedwick:patch-1, r=micbou
Add VimL syntax highlighting to Readme
2015-09-16 06:08:33 +09:00
Chris DeLuca
1eafd4981d Add VimL syntax highlighting to Readme 2015-09-15 14:57:34 -04:00
Homu
e60fa3f138 Auto merge of #1679 - puremourning:typescript-subcommands, r=Valloric
Update subcommmands supported for typescript

Noticed that the subcommands supported by typescript are not listed. Updated the docs and ran

```
vim-tools/html2vimdoc.py -f youcompleteme README.md > doc/youcompleteme.txt
```
2015-09-15 13:03:30 +09:00
Homu
0d426e4922 Auto merge of #1636 - mispencer:CsAddImport, r=puremourning
Add required namespace in C# after completing

When forcing semantic completion with the keybind, C# completions can return a list of importable types. These types are from namespaces which havn't been imported, and thus are not valid to use without also adding their namespace's import statement. This change makes YCM automatically insert the necessary using statement to import that namespace on completion completion. In the case there are multiple possible namespaces, it prompts you to choose one.

Demo:
![c namespaceinsertdemo](https://cloud.githubusercontent.com/assets/1434266/9337289/b7994542-459b-11e5-8f52-e48af76a3aab.gif)

By default, the using statement is inserted after the last using statement. If there aren't any, it's inserted before the first line. This behavior is customization by setting a function to the vim global ``g:ycm_cs_insert_namespace_function``. I implemented this in pure vimscript largely so I could provide such customization...

Caveats: vim does not provide a way to get which completion was inserted. To get this, we store the completions, hook the CompleteDone event, and check than if the preceding text matches any of the completions. This is imperfect, and sometimes matches when it shouldn't. Also, the CompleteDone event requires 7.3.598 or newer.
2015-09-14 00:48:30 +09:00
Spencer G. Jones
bb21150798 Fix merge test failure 2015-09-13 08:57:09 -06:00
Spencer G. Jones
2a41101955 Merge remote-tracking branch 'origin/master' into CsAddImport 2015-09-13 08:49:28 -06:00
Ben Jackson
7c2b7b7ef3 Update subcommmands supported for typescript 2015-09-13 13:01:11 +01:00
Homu
a4f7d02a3b Auto merge of #1676 - micbou:fix-it-chunks-sorting, r=Valloric
Correct FixIt chunks sorting

While playing with FixIts in C++, I found the following issue. When fixing the third line in the code:
```cpp
template<int Value> struct CT { template<typename> struct Inner; };

CT<10 >> 2> ct; // expected-warning{{require parentheses}}
```
the following result is obtained:
```cpp
CT<1(0 >> 2)> ct; // expected-warning{{require parentheses}}
```
which is obviously wrong.

The issue is YouCompleteMe does not replace the chunks in the right order. It starts by adding the closing parenthesis, add one to the delta and inserts the opening parenthesis in the wrong place cause of the delta.

We actually use the expression `str(line) + ',' + str(column)` to sort the chunks by line then column whereas it should simply be `(line, column)`.

This PR fixes this issue, adds two tests which are failing in the current version, refactors the `_HandleFixitResponse` function and cleans up code.
2015-09-13 13:48:54 +09:00
Homu
9d8e85d363 Auto merge of #1677 - puremourning:add-clang-brief-to-preview, r=Valloric
Show docs from clang completer in preview window

Fixes https://github.com/Valloric/YouCompleteMe/issues/106

We add the detailed_info (which is the function definiton) followed by the brief comment if supplied.

I added a test for the method, which is now reasonably complex.
2015-09-13 13:28:09 +09:00
Ben Jackson
5cfd6376c6 Show docs from clang completer in preview window
We add the detailed_info (which is the function definiton)
followed by the brief comment
2015-09-12 20:51:04 +01:00
micbou
8c17995bee Correct FixIt chunks sorting 2015-09-12 18:14:06 +02:00
micbou
17f5f20cd6 Add chunks sorting tests 2015-09-12 18:14:05 +02:00
micbou
2c72a3c598 Clean code in vimsupport tests 2015-09-12 18:14:04 +02:00
micbou
33316d8bf8 Refactor _HandleFixitResponse function 2015-09-12 18:13:54 +02:00
Spencer G. Jones
df73ca6b66 Update g:ycm_csharp_insert_namespace_expr documention 2015-09-11 17:14:09 -06:00
Spencer G. Jones
391b3df3b7 Update mimimum version in documention 2015-09-10 10:12:59 -06:00
Spencer G. Jones
28e318c0bb fixup! To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-10 09:18:48 -06:00
Spencer G. Jones
af4aaa1d17 fixup! To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-09 09:08:41 -06:00
Spencer G. Jones
9f134c4dd0 To determine which completion prompted CompleteDone, look at the new variable if vim is recent enough. 2015-09-09 08:27:15 -06:00
Strahinja Val Markovic
a2808ee3ff Updating to latest ycmd 2015-09-01 19:51:16 -07:00
Homu
886787ff17 Auto merge of #1662 - micbou:table-of-contents, r=Valloric
Update table of contents in README

Remove Project Management entry.
2015-09-02 11:18:12 +09:00
micbou
9fc26130ef Update table of contents in README
Remove Project Management entry.
2015-09-02 01:54:05 +02:00
Spencer G. Jones
9f568be39a fixup! Add CompleteDone hook, with namespace insertion for C# 2015-08-31 10:51:23 -06:00
Homu
f94b342989 Auto merge of #1659 - puremourning:cwd-filetype-completer, r=Valloric
Pass cwd to completer for filename completions

Required for https://github.com/Valloric/ycmd/pull/210. Please see that PR for functional and testing details.
2015-08-31 02:58:30 +09:00
Homu
042fea73f8 Auto merge of #1657 - micbou:travis-badge, r=Valloric
Use SVG Travis badge instead of PNG

Because badges need consideration (and it [still](https://github.com/Valloric/ycmd/pull/207) looks better).
2015-08-31 02:16:44 +09:00
Spencer G. Jones
dd27184970 Add CompleteDone hook, with namespace insertion for C#
Add a new vim hook on CompleteDone. This hook is called when a
completions is selected.

When forcing semantic completion with the keybind, C# completions can
return a list of importable types. These types are from namespaces which
havn't been imported, and thus are not valid to use without also adding
their namespace's import statement. This change makes YCM automatically
insert the necessary using statement to import that namespace on
completion completion. In the case there are multiple possible
namespaces, it prompts you to choose one.
2015-08-28 10:05:46 -06:00
Spencer G. Jones
7e9333a9c2 VimVersionAtLeast was not "at least" for minor/major version differences 2015-08-28 08:26:04 -06:00
micbou
dab5ab1d72 Use SVG Travis badge 2015-08-28 00:44:51 +02:00
Ben Jackson
fa32819d4f Pass cwd to completer for filename completions 2015-08-26 23:41:40 +01:00
Homu
b5bf25564c Auto merge of #1646 - FooSoft:master, r=Valloric
Fixing install script

Fixing issue #1645 where the `subprocess.call` was being incorrectly used, preventing install. Also made `install.py` be executable so that you can run it directly from shell instead of having to execute `python install.py`
2015-08-26 13:11:44 +09:00
Alex Yatskov
36ad5510e5 Make install.py be executable 2015-08-25 13:15:52 +09:00
Alex Yatskov
1348c0a53d Fixing install script. 2015-08-25 13:13:27 +09:00
Homu
b7e9871801 Auto merge of #1644 - micbou:python-run-tests, r=Valloric
[Windows support] Convert run_tests script to python

By converting run_tests script to python, we can run tests on Windows.
2015-08-25 10:17:34 +09:00
Homu
d7f641c3d1 Auto merge of #1642 - micbou:windows-support, r=Valloric
[Windows support] Convert the install script to python

Allow Windows users to run the script. 

Documentation updated.
2015-08-25 10:02:08 +09:00
micbou
0588c23c70 Update Travis configuration 2015-08-23 23:27:13 +02:00
micbou
c99aa85de2 Convert run_tests script to python
Translate the run_tests.sh script in python to make it platform independent.
2015-08-23 23:27:02 +02:00
micbou
7d87bc3f82 Update documentation 2015-08-23 20:12:24 +02:00
micbou
1b40d683be Convert the install script to python
Translate the install.sh script in python to make it platform independent.
Keep install.sh as a wrapper of install.py to not break scripts that
depend on it.
2015-08-23 20:12:16 +02:00
Homu
cc94a96c9d Auto merge of #1641 - RyuKojiro:bashless, r=Valloric
Removed the bash dependency that install.sh had

People like me use YCM on machines that don't have bash, and it's nice to not have to add it unnecessarily. This removes the bash dependency for installation.
2015-08-22 13:49:11 +09:00
Daniel Loffgren
dd143bcaaa install.sh now works without bash, and preserves the trap functionality via exits 2015-08-21 03:22:09 +09:00
Strahinja Val Markovic
689b4e15a5 Rewording the YCM readme intro section
It's time to break the semantic language support up into bullets.
2015-08-18 20:11:39 -07:00
Strahinja Val Markovic
5fb4146a49 Updating to latest ycmd 2015-08-18 20:07:46 -07:00
Homu
33621d409b Auto merge of #1632 - puremourning:general-completions-when-no-semantic, r=Valloric
If errors are returned in addition to completion suggestions, print them

Needed for https://github.com/Valloric/ycmd/pull/198

This maintains the previous client behaviour when the semantic completer throws an exception.
2015-08-19 11:30:30 +09:00
Ben Jackson
258951ece4 If errors are returned in addition to completion suggestions, print them 2015-08-17 01:13:20 +01:00
Homu
9430aee4b3 Auto merge of #1628 - puremourning:update-vim-doc, r=Valloric
Update vim help

Includes recent changes including FixIt and some other minor tweaks
2015-08-17 00:52:33 +09:00