Commit Graph

707 Commits

Author SHA1 Message Date
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
5dca552d5d
Do not depend on UltiSnips internals
Use UltiSnips#SnippetsInCurrentScope to fetch snippets.
Add an entry in the FAQ about the :UltiSnipsAddFiletypes command.
2016-09-11 17:11:32 +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
d3916a8752 Extract keywords from whole PreProc syntax group
Reorder syntax groups to follow documentation order.
2016-08-09 11:59:35 +02:00
micbou
75d41d1137 Improve extraction of syntax keywords
Use the following strategy to extract identifiers from syntax
highlighting:
 - ignore match and region: they mostly contain arguments,
   syntax groups and regular expressions;
 - ignore "nextgroup=" if first word and subsequent arguments
   "skipempty", "skipwhite", and "skipnl";
 - ignore "contained" argument if first word;
 - add remaining words to the list of identifiers.
Fix a bug where the word "match" was extracted while not being a keyword
of the syntax language.
2016-08-06 13:39:06 +02:00
micbou
f14485acb9 Rewrite syntax tests
Use matchers from hamcrest instead of eq_ assertions in syntax tests
to get more detailed assertion errors when tests are failing.
2016-08-06 01:12:59 +02:00
micbou
7b2155ab64 Refactor tests using a server instance
Create a Server_test class for tests that need a server instance.
2016-07-23 11:21:38 +02:00
micbou
630b85ad01 Use shutdown request to stop server
Use shutdown request to stop ycmd server in a portable way.
2016-07-23 11:21:20 +02:00
micbou
899746d51c Convert Vim buffers to bytes in ReplaceChunk 2016-07-14 02:39:33 +02:00
micbou
a986b3ed0e Update ReplaceChunk tests
Do not convert strings to bytes but instead use plain strings to mimic
Vim buffers returning a list of byte objects on Python 2 and unicode
objects on Python 3.
2016-07-14 00:46:30 +02:00
Ben Jackson
cfd4bbd531 Support selecting from the list of FixIts when multiple are supplied 2016-07-11 21:52:41 +01:00
micbou
805911b56b Use SetQuickFixList for GoTo* subcommands
Open the quickfix window to full width at the bottom of the screen with
its height set to fit all entries. This behavior can be overridden by
using the YcmQuickFixOpened autocommand.
Add a new section for autocommands in the documentation.
Update GoTo and ReplaceChunks tests.
2016-06-13 00:25:12 +02:00
Homu
e0f2da0885 Auto merge of #2160 - micbou:open-file-encoding, r=Valloric
[READY] Fix LookupError exception when opening a file

Fixes #2159.

I think the issue is caused by `locale.getpreferredencoding()` returning an empty string on some configurations (especially on OS X with Python 2). This is [the value used by default when no encoding is specified](https://docs.python.org/2/library/io.html?highlight=open#io.open). The same error is raised if we do:
```python
open( 'some_file', encoding = '' )
```

For references, similar issues: https://github.com/Valloric/ycmd/issues/395, https://github.com/Valloric/ycmd/issues/419

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2160)
<!-- Reviewable:end -->
2016-05-11 02:01:22 +09:00
micbou
b0786d5c4f Fix LookupError exception when opening a file
Open the file in binary mode in CheckFilename function.
Use ReadFile helper in syntax_parse tests.
2016-05-10 16:30:04 +02:00
Ben Jackson
e73426187d Add tests for omni completer GetCompletions 2016-05-08 15:47:58 +01:00
Ben Jackson
4d7b386a37 Fix a number of multi-byte errors and tracebacks
- Correct FixIts when there are unicode characters
- Fix errors in CompleteDone handler
- Fix tracebacks when omnifunc returns unicode chars
2016-05-08 15:32:36 +01:00
micbou
b923431d7d Avoid evaluating Vim globals in Python
On Python 3, evaluating a Vim expression will raise a unicode exception
if it contains an invalid sequence of bytes for the current encoding.
We can't really do anything about it because this is the way Vim and
Python 3 interact. However, we can prevent this situation to occur by
not evaluating Vim data that we have no control over: in particular,
the Vim globals. This is done by:
 - adding one by one the YCM default options instead of extending the
   Vim globals with them;
 - only evaluating the Vim global variable names (and not their values)
   when building the YCM options for the ycmd server.
2016-05-06 20:14:10 +02:00
micbou
b440f682a8 Add error messages when ycmd crashed
Display an error message to the user depending on the status code
returned by the ycmd server.
Remove ycm_core checks in plugin/youcompleteme.vim. These checks are
now done by the ycmd server.
Do not start a separate process to check the core version but rely on
ycmd returning a specific exit code. This slightly improves the Vim
startup time.
2016-05-02 23:08:32 +02:00
Val Markovic
8fe90b43c4 Starting ycmd with Python used to build it
Note: depends on Valloric/ycmd#466 being merged and the ycmd submodule
ref then being updated.

Fixes #2136
2016-04-27 19:42:00 -07:00
micbou
638550384e Update PostComplete tests
Move with-statement patch as decorator when possible.
Use single quote everywhere instead of double quote (for consistency).
Remove empty lines.
2016-04-07 00:42:43 +02:00
micbou
4b9e16f14d Fix PostComplete test
ReturnEmptyIfPendingMatches_OldVim test was identical to
ReturnEmptyIfPendingMatches_NewVim.
2016-04-07 00:42:43 +02:00
Andrea Cedraro
9e6645f515 Rename ycmd python option
- Rename ycm_path_to_python_interpreter to ycm_ycmd_python_interpreter
- Keep ycm_path_to_python_interpreter backward compatible
2016-03-26 19:15:08 +01:00
Ben Jackson
953885c449 Fix traceback when a syntax file has unicode characters
vim.eval returns a str() object on py2, but our internal strings are all unicode().
We use vimsupport.VimExpressionToPythonType to wrap the conversion complexities.
2016-03-10 21:28:42 +00:00
micbou
d59dfb0a7e Do not send request if server is down
Do not send an "event_notification" request in OnFileReadyToParse
function if server process is terminated. Otherwise, it blocks Vim
for one second or results in a traceback each time the InsertLeave,
CursorMoved, CursorHold, and BufferVisit events are triggered.
2016-03-09 16:53:20 +01:00
Ben Jackson
edd2bdbe0f Update flake8 config 2016-03-06 17:39:55 +00:00
micbou
f6d5f68d6b Catch ReadTimeout exception on requests 2016-03-05 22:34:45 +01:00
Val Markovic
0bcecb14d8 Fixing conversion bug in VimExpressionToPythonType
Bug was that objects other than strings/bytes were being converted to
strings. Also added tests.
2016-03-05 10:16:08 -08:00
Val Markovic
74f5e5ef34 Using non-emacs version of python coding line 2016-03-02 18:12:38 -08:00
Val Markovic
80631b1aaf Enforcing unicode in more vimsupport functions 2016-03-01 19:30:02 -08:00
Val Markovic
c91130f280 Not depending on exception internals
We used to read the `message` attribute; that breaks on py3. The
standard idiom is to just use `str( exception )` to get the message.
2016-03-01 19:30:02 -08:00
Val Markovic
0ed1096040 Support multiline exception message
Also stopped adding the "ycmd exception:" prefix to error messages
because it lies; some exceptions hitting this may not come from ycmd.
2016-03-01 19:29:21 -08:00
micbou
f981370965 Fix CheckFilename test on Windows and Py2
On Windows and Python 2, the full exception message from IOError
in CheckFilename will contain the filepath formatted as a unicode
string. Since the filepath is already added in the RuntimeError
message, use the strerror attribute to only display the error.
2016-02-29 20:06:01 +01:00
micbou
fae95812dc Simplify YouCompleteMe test
Add missing python-future boilerplate.
2016-02-29 20:06:01 +01:00
micbou
b78c403cfe Clean up YCM object in PostComplete tests
Move PostComplete tests inside a class that defines setUp and tearDown
methods. Clean YCM object in tearDown method. This fixes the error
"OSError: [WinError 6] The handle is invalid" on Windows with
Python 3.5.
2016-02-29 20:06:01 +01:00
Val Markovic
eb8a24f23d Addressing review comments 2016-02-29 10:26:50 -08:00
Val Markovic
1c65c96e65 Fixing bad comparison causing ToggleLogs to fail
`is` in Python checks for identity, not equality.
2016-02-28 20:24:53 -08:00
Val Markovic
be1bb3617d Minor tweaks 2016-02-28 19:23:40 -08:00
Val Markovic
8c0192ecf7 Can now select python3 for running ycmd 2016-02-28 19:23:40 -08:00
Val Markovic
ba6c6182ed Consistent handling of ServerError exceptions
Previously we used the super-evil 'except Exception' clauses that would
catch everything and turn debugging into a sanity-questioning exercise.
2016-02-28 19:23:40 -08:00
Val Markovic
43b2dd44f2 Ensuring vimsupport only returns unicode text
Python 3 is much stricter around mixing bytes with unicode (and by
"stricter," I mean it doesn't allow it at all) so we're making
vimsupport only return `unicode` objects (`str` on py3). The idea is
that YCM (and ycmd) internals only ever deal with unicode.
2016-02-28 19:23:40 -08:00
Val Markovic
123c5c4acb Fixing ycmd startup under py3
Some syntax rules are different for py3 plus the standard bytes vs
unicode nonsense.
2016-02-28 14:41:09 -08:00
Val Markovic
92346d2bcc Import order fixes for py3
The import machinery works differently in py3, so some massaging is in
order.
2016-02-28 14:39:55 -08:00
Val Markovic
1e72f4d421 Making it clearer an exception came from ycmd
Makes debugging easier when you know where the error lies.
2016-02-28 14:38:23 -08:00
Val Markovic
1941d8bfb2 Fixing issues with bytes vs unicode for hmac 2016-02-27 17:38:38 -08:00
Val Markovic
4e82409cc1 Futurize pass + manual fixes 2016-02-27 16:12:44 -08:00
Homu
cb8607796e Auto merge of #2004 - Valloric:new-omni, r=micbou
[READY] Updating to latest ycmd

This includes the using the new API for OmniCompleter.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/valloric/youcompleteme/2004)
<!-- Reviewable:end -->
2016-02-27 08:28:18 +09:00
micbou
298c318bc7 Add test to check if ycm_core is not imported 2016-02-25 02:17:57 +01:00