Commit Graph

133 Commits

Author SHA1 Message Date
Ben Jackson
dc52b73048 Don't open the quickfix window after fixit 2018-02-22 23:02:10 +00:00
micbou
5d2258bdd4
Convert Vim command output to Unicode 2018-02-20 10:43:29 +01:00
zzbot
54a4ecf2d9
Auto merge of #2922 - micbou:improve-diagnostic-match, r=bstaletic
[READY] Improve diagnostic matches display

There are two issues with how we display diagnostic matches. The first issue is that if the current buffer contains diagnostic matches and is split in a new window, all the matches are cleared and only matches in the new window are shown. The second issue is that if a new buffer with no diagnostic support is open in the current window and that window already contained matches then the matches are still displayed. Here's an illustration of both issues (signs are disabled):

![diagnostic-matches-issue](https://user-images.githubusercontent.com/10026824/36352338-bfeb2092-14b7-11e8-88f4-ae8cf6903304.gif)

The solution is to add an autocommand that updates matches on the `BufEnter` and `WinEnter` events. Here's the result:

![diagnostic-matches-fix](https://user-images.githubusercontent.com/10026824/36352340-c2a64a8c-14b7-11e8-8db2-4f1f54448c65.gif)

Note that it's not perfect as multiple windows of the same buffer won't be updated simultaneously. Supporting that scenario is rather tricky because we would need to go through all the windows to update the matches and switching windows can lead to a lot of issues (like interrupting visual mode) so we don't.

This PR also improves how we update matches by only displaying matches that are not already present and then clearing the remaining ones (similarly to what we do with signs; see PR https://github.com/Valloric/YouCompleteMe/pull/2915) instead of always clearing all the matches then displaying the new ones.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2922)
<!-- Reviewable:end -->
2018-02-18 17:15:46 -08:00
micbou
c84e70737c
Improve diagnostic matches display 2018-02-18 21:32:00 +01:00
micbou
b182556804
Add function to capture Vim command output 2018-02-18 14:06:09 +01:00
micbou
5e98da5b09
Improve diagnostic sign placement 2018-02-18 10:46:19 +01:00
micbou
a13329fe94
Add range support to completer command 2018-02-12 01:50:08 +01:00
Ben Jackson
7989b7b0fd Support for additional FixIts on java completions
Java completer can include FixIts which are applied when a completion
entry is selected. We use the existing mechanism implemented for c-sharp
to perform these edits using the CompleteDone autocommand.

However, the existing mechanism relies on pattern matching the source to
work out which item was completed. Vim patch 8.0.1493 introduces support
for user_data on completion items, so when available we populate it with
the completion array index of the item and use that to get the exact
element that was selected. This is both a lot faster and a lot more
accirate.

Of course when applying these 'FixIts' we don't interrupt the user with
confirmation or the quickfix list as this would just be annoying. If the
server reports that an edit must be made, we just make the edit. This is
achieved by adding a silent flag to ReplaceChunks.
2018-02-11 18:11:34 +00:00
zzbot
39fe6d1f86
Auto merge of #2898 - micbou:line-overlapping-chunks, r=micbou
[READY] Apply chunks from bottom to top

Without the proposed fix, the test included in that PR fails as follows
```
FAIL: ycm.tests.vimsupport_test.ReplaceChunksInBuffer_LineOverlappingChunks_test
----------------------------------------------------------------------
Traceback (most recent call last):
  File "C:\Python36\lib\site-packages\nose\case.py", line 198, in runTest
    self.test(*self.arg)
  File "C:\Users\micbou\projects\YouCompleteMe\python\ycm\tests\vimsupport_test.py", line 768, in ReplaceChunksInBuffer_LineOverlappingChunks_test
    AssertBuffersAreEqualAsBytes( expected_buffer, result_buffer )
  File "C:\Users\micbou\projects\YouCompleteMe\python\ycm\tests\vimsupport_test.py", line 86, in AssertBuffersAreEqualAsBytes
    eq_( ToBytes( result_line ), ToBytes( expected_line ) )
AssertionError: b'    third line' != b'    third '
```
Found the issue while trying to add code formatting support to the language server completer. The test is based on a real-world scenario when formatting with jdt.ls (for some reason, jdt.ls is including the newline of the previous line when fixing indentation).

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2898)
<!-- Reviewable:end -->
2018-02-10 15:20:24 -08:00
micbou
c692b48bc6
Apply chunks from bottom to top 2018-02-10 21:42:41 +01:00
Ben Jackson
292de25c72 Add support for Java diagnostics and asynchronous messages
This implements an asynchronous message system using a long-poll request
to the server.

The server provides an endpoint /receive_messages which blocks until
either a timeout occurs or we receive a batch of asynchronous messages.
We send this request asynchronously and poll it 4 times a second to see
if we have received any messages.

The messages may either be simply for display (such as startup progress)
or diagnostics, which override the diagnostics returned by
OnFileReqdyToParse.

In the former case, we simply display the message, accepting that this
might be overwritten by any other message (indeed, requiring this), and
for the latter we fan out diagnostics to any open buffer for the file in
question.

Unfortunately, Vim has bugs related to timers when there is something
displayed (such as a "confirm" prompt or other), so we suspend
background timers when doing subcommands to avoid vim bugs. NOTE: This
requires a new version of Vim (detected by the presence of the
particular functions used).
2018-02-10 16:29:27 +00:00
Boris Staletic
bb7bbdb974 Fix truncation
When the message is exactly as wide as the vim window, vim still
displays "press enter..." message.

Wen we want to avoid that we need to cut the message one character
shorter.
2018-01-30 19:26:22 +01:00
micbou
43ebd5252d
Optimize request building
Reduce the time spent to build the request when there are a lot of buffers by:
 - using the options property on the buffer object to get the mod variable
instead of evaluating getbufvar;
 - not computing the buffer filepath if the buffer is not modified;
 - passing the number of the unloaded buffer instead of its filepath on the
   BufferUnload event. Getting the Python buffer object from its number is
   easier than from its filepath.
2018-01-09 01:40:07 +01:00
micbou
497a803188
Prompt the user to select a logfile with YcmToggleLogs
When no argument is given to the YcmToggleLogs command, instead of displaying
the list of available logfiles, prompt the user to open (or close if already
open) one of them.
2017-12-22 19:58:29 +01:00
zzbot
2dd27db859 Auto merge of #2838 - micbou:normalize-buffer-filepath, r=micbou
[READY] Normalize buffer filepath

On Windows, Vim returns buffer filepaths with forward slashes instead of backward ones if [the `shellslash` option](http://vimdoc.sourceforge.net/htmldoc/options.html#'shellslash') is set. Since the server always return paths with backslashes on that platform, [the paths comparison in `JumpToLocation`](e8e144d446/python/ycm/vimsupport.py (L409)) will incorrectly return `True` for two equivalent paths. We need to normalize the paths from Vim.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2838)
<!-- Reviewable:end -->
2017-12-01 22:23:33 -08:00
micbou
b1eda652c3
Normalize buffer filepath
On Windows, Vim returns buffer filepaths with forward slashes instead of
backward ones if the shellslash option is set. Since we always expect backward
slashes from the server, we normalize these paths.
2017-12-01 17:55:15 +01:00
micbou
c3859791ea
Use fnameescape to escape filepath 2017-12-01 17:54:45 +01:00
micbou
67d2a0fbf8
Fix error when filetype is a number
The VimExpressionToPythonType function automatically convert a number
represented as a string to an integer. This causes an error when used to
evaluate a filetype set to a number as the result is split on the dot character
to get a list of filetypes and an integer cannot be split. Use vim.eval and
ToUnicode instead.
2017-11-26 16:44:35 +01:00
micbou
664d2c99d9
Change GetBufferNumberForFilename default behavior
If no buffer exists for a given filename, the GetBufferNumberForFilename
function will create a buffer for that file by default. This behavior is
unexpected given the name of that function and may lead to performance issues
when ycmd returns diagnostics for a lot of files with no corresponding buffers.
The default behavior for that function should be to not create a buffer.
2017-11-17 00:52:40 +01:00
micbou
d61944098a
Do not open location list at the bottom of screen
The location list is specific to the current window so it should be opened
inside the current window, not to full width at the bottom of the screen.
2017-09-17 20:34:52 +02:00
micbou
83bb78a2d6
Restore cursor position after omnifunc call
Calling directly the omnifunc may move the cursor position. This is the case
with the default Vim omnifunc for C-family languages (ccomplete#Complete) which
calls searchdecl to find a declaration. This function is supposed to move the
cursor to the found declaration but it doesn't when called through the omni
completion mapping (CTRL-X CTRL-O). So, we restore the cursor position after
calling the omnifunc.
2017-07-07 03:38:33 +02:00
micbou
81546b901e
Fix HiddenEnabled function
The 'hidden' option is a global option, not a buffer one. If this option is
false, we should check if the 'bufhidden' option, which is local to the buffer,
is set to 'hide'. If so, the buffer can be hidden despite the 'hidden' option
being false.
2017-07-05 19:56:13 +02:00
micbou
e573457563
Convert buffer name to unicode
Fix JumpToLocation tests on Python 2.
2017-07-05 02:25:30 +02:00
zzbot
44d4f1d299 Auto merge of #2690 - micbou:identifier-functions-codepoint, r=Valloric
[READY] Use codepoint offsets in identifier functions

`CurrentIdentifierFinished` and `LastEnteredCharIsIdentifierChar` incorrectly use byte offsets with unicode lines (`CurrentColumn` returns a byte offset and `CurrentLineContents` a unicode string). This leads to weird bugs when there is a non-ASCII character on the current line:

![unicode-identifier-bug](https://user-images.githubusercontent.com/10026824/27256590-34b27c8c-53ba-11e7-8032-b98f0c7e0b14.gif)

This is fixed by converting byte offsets to codepoint ones through the `ByteOffsetToCodepointOffset` function.

This changes the behavior of these two functions when the current column position is invalid. Both functions returned false in that case. They now return as if the current column were at the end of the line. In practice, this doesn't really matter since the position of the current column should always be valid.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2690)
<!-- Reviewable:end -->
2017-06-18 12:29:13 -07:00
micbou
eb3c0cd8c1
Use codepoint offsets in identifier functions
CurrentIdentifierFinished and LastEnteredCharIsIdentifierChar incorrectly use
byte offsets with unicode lines. Convert those offsets to codepoint offsets.
2017-06-18 20:41:30 +02:00
Davit Samvelyan
22be4e777d Refactored diag interface, removed dummy sign. 2017-06-05 22:20:57 +04:00
Davit Samvelyan
fc745f74b3 Minor changes addressing review comments. 2017-05-29 22:24:55 +04:00
Davit Samvelyan
0846673aa4 Latest upstream changes with buffer emulation.
Contains diagnostic interface improvents as well.
2017-05-21 18:26:50 +04:00
micbou
1fc6b4a43b
Clean C# inserting namespace code
Remove code that automatically insert namespaces in C# for Vim versions prior
to 7.4.774.
2017-05-17 19:44:02 +02:00
micbou
e45a409ac9
Prioritize errors over warnings on the same line 2017-03-29 12:34:48 +02:00
micbou
f3ccafe3ae
Do not install aliases from future
Installing aliases from python-future is unreliable and slow.
2017-03-18 18:24:48 +01:00
micbou
0d476a0164
Refactor diagnostic commands
Move s:ShowDiagnostics and s:ForceCompileAndDiagnostics logic to the Python layer.
Clear message about compilation blocking Vim once it is done.
2017-02-20 18:28:49 +01:00
Andrea Cedraro
fda5c7e6c6 Use bang version of normal
Fixes #2519
2017-01-31 22:09:40 +01:00
micbou
b93c1fd47c
Add client logfile 2016-11-19 18:47:43 +01:00
Nader Akoury
f4f12f3c9b Fix another test failure
* Because I cannot seem to run the tests locally I am relying on the CI
tests which kind of sucks...
2016-11-11 11:28:20 -08:00
Nader Akoury
659746eaaf Doh, forgot to revert my previous changes. Fixed! 2016-11-11 10:53:26 -08:00
Nader Akoury
9c93244d3b Addressed review comments and fixed tests 2016-11-11 10:15:22 -08:00
Nader Akoury
74951adcc7 Address #1366 by reusing a single preview buffer
* Additionally set the preview buffer to be unlisted so it does not
interfere with commands like :bnext
2016-11-11 07:53:01 -08:00
dhleong
8eabf580ad Rename argument 2016-11-03 13:47:26 -04:00
dhleong
0babb4b102 Cleanup 2016-11-03 11:21:15 -04:00
dhleong
0523ad02c0 Fix InsertNamespace indent matching
Aso updates the appropriate tests and adds docs to some
relevant methods whose behavior might be confusing
2016-11-02 08:08:30 -04:00
dhleong
62a815275f Fix InsertNamespace
ReplaceChunk must have changed to require the buffer at some point
2016-10-31 17:00:45 -04:00
micbou
234658f30b
Use helper function to get current directory
Fix tests.
2016-10-18 15:35:51 +02:00
micbou
2fabac5a67
Fix BufferUnload event notification
Send the request as the unloaded buffer instead of the current buffer
for the BufferUnload event notification. This fixes the issue where
the filetype of the current buffer is not the same as the unloaded
buffer one, making the ycmd server uses the wrong completer when
handling the request.
2016-10-08 16:43:50 +02:00
Justin Lebar
a33f20d690 Update ycmd, and use JoinLinesAsUnicode in GetUnsavedAndCurrentBufferData().
This function is invoked on every kepress.  On a large file (15+k loc),
using this new function takes kepress latency down to <10ms from ~100ms.
2016-10-07 18:27:09 -07:00
micbou
981a07ded7
Handle keyboard interruption from Vim 2016-09-13 00:53:31 +02:00
micbou
391757eec2 Avoid hit-enter prompts during completions
When an error occurs during completions, a message is displayed on
the status line. If this message is longer than the width of the
current window, Vim will prompt the user to press enter or type a
command to hide the message, interrupting user workflow. We prevent
that by truncating the message to window width.
Merge PostMultiLineNotice, EchoText, and EchoTextVimWidth functions
into PostVimMessage.
2016-08-28 09:19:07 +02:00
micbou
ef49f3e052 Fix diagnostic highlighting at line ending
When columns are clamped to not be past the contents of the line for
highlighting diagnostics, we need to account for the column end not
being included in the diagnostic range.
2016-08-18 21:21:10 +02:00
micbou
899746d51c Convert Vim buffers to bytes in ReplaceChunk 2016-07-14 02:39:33 +02:00
Ben Jackson
cfd4bbd531 Support selecting from the list of FixIts when multiple are supplied 2016-07-11 21:52:41 +01:00