[READY] Improve extraction of keywords from syntax list
This PR is an attempt at improving the extraction of keywords from Vim syntax files. Current approach is to go through the `syntax list` output and:
- ignore lines where the first word is a reserved keyword for syntax highlighting except for `contained`;
- ignore all words used by Vim as arguments in the syntax commands;
- add remaining words to the list of identifiers.
The main issue with this approach is that syntax arguments that could be valid language keywords are always ignored. There is also a bug where the `match` keyword is extracted while not being a language keyword (see the Python, C++, and Java tests).
With the new approach, we try to ignore Vim keywords only when necessary, that is:
- ignore `syntax match` (fix the `match` keyword bug) and `syntax region` commands: they mostly contain arguments, syntax groups and regular expressions;
- ignore `nextgroup=` if in first position and subsequent arguments `skipempty`, `skipwhite`, and `skipnl`;
- ignore `contained` argument if in first position;
- add remaining words to the list of identifiers.
This strategy is based on observations of the `syntax list` output.
<!-- 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/2274)
<!-- Reviewable:end -->
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.
[READY] Rewrite syntax tests
While trying to fix a bug when extracting identifiers from Vim syntax files, I found out that errors from syntax tests are not really helpful because `eq_` assertions don't tell which items are missing when comparing lists (or sets). So, we use matchers from hamcrest instead to get useful assertion errors.
Note that with these changes, we don't test anymore if the value returned by `_KeywordsFromSyntaxListOutput` is a set. I don't think it's an issue but if you feel that's important, we can probably check for it too.
<!-- 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/2273)
<!-- Reviewable:end -->
[READY] Implement shutdown handler
This PR depends on https://github.com/Valloric/ycmd/pull/282.
We don't want to block Vim exit if the server takes too much time to answer the shutdown request so we use a timeout of 100ms for this request. In my experience, it takes ~5ms.
The `YcmStopServer` command only exists for testing purpose. It will be removed in the final version of this PR.
Fixes#876.
<!-- 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/2245)
<!-- Reviewable:end -->
[READY] Fix Python 3 bytes issue in ReplaceChunk function
This PR updates the `ReplaceChunk` tests by using plain strings instead of byte objects to mimic Vim buffers returning byte objects on Python 2 and unicode objects on Python 3.
We are only updating the tests for now to show that these changes make the tests fail on Python 3 with the same error as issue #2240.
Fixes#2240.
<!-- 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/2242)
<!-- Reviewable:end -->
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.
[READY] Support selecting from the list of FixIts when multiple are supplied
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [X] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [X] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [X] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
See PR https://github.com/Valloric/ycmd/pull/532
This PR presents the user with a list to choose from supplied FixIt suggestions when there are multiple suggestions on the same line. This not only helps with the child diagnostics mentioned in the ycmd PR, but also for cases where there are simply 2 diagnostics on the current line; the user can now select which of them to apply. Previously the one closest to the cursor was applied (which was always the first one supplied from the server).
I created a new `SelectFromList` method which uses `inputlist()` as the user interface from `confirm()` does not work well with long prompts. This interface is more like the suggestions when `set spell` is enabled, which should be familiar to many Vim users.
I considered updating the "auto namespace import" c sharp stuff to use the new `SelectFromList` method, but we know that the current implementation of that functionality is broken, so cannot be widely used.
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
<!-- 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/2223)
<!-- Reviewable:end -->
Support lazy loading with :packadd.
- [X] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [X] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [X] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
Vim recently has introduced a new feature called 'packages', which
permits, among the rest, to disable automatic loading a plugin at
startup. Plugins that are disabled at startup may be manually loaded
during a session using `:packadd` (see `:h packages`, `:h :packadd`).
Of course, a plugin that is loaded after startup cannot rely on VimEnter
events.
In order to support lazy loading YCM, check whether YCM is sourced
during startup or at a later time. In the former case, define an
autocommand as before; in the latter case, enable YCM immediately.
Why would one want to load YCM lazily? I use YCM only for certain file
types (Python), and I prefer not to have pop up menus appearing
all the time for other file types. In my workflow, I may enable YCM only
if I start Vim for Python coding sessions.
Tests not included because the change is in VimScript code only, and
testing this feature is not trivial.
<!-- 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/2084)
<!-- Reviewable:end -->
[RFC] Document find first executable for ycm_python_binary_path
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [x] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [x] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
This will document the enhancement that https://github.com/Valloric/ycmd/pull/429 brought to YCM. When this will be ready I will update the vim documentation too.
[Please explain **in detail** why the changes in this PR are needed.]
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
<!-- 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/2205)
<!-- Reviewable:end -->
[READY] Use SetQuickFixList function for GoTo* subcommands
From discussion in PR #2101, we reuse the `SetQuickFixList` function for the `GoTo*` subcommands. This automatically makes the quickfix window height equal to the number of locations.
Unfortunately, there is no Vim option to change the default height (10) of the quickfix window so we can't really use the heuristic `min(number of Locations, default height)` because users would not be able to change the default height (and we don't want to add another option). However, there are still solutions to set a default height. For instance, a user could add the following line in its vimrc:
```viml
autocmd FileType qf exe "20wincmd _"
```
to set the default height to 20. This will override YCM behavior.
I didn't reproduce the `lazyredraw` boilerplate from `youcompleteme#OpenGoToList`. I guess it was used to avoid flickering but I didn't experienced any without it. In addition, it was not properly implemented because the `lazyredraw` state was not preserved if the option was already set.
I also threw away the `cclose` command. It resets the quickfix window to its default position if already opened, which I think is not a desirable behavior.
Closes#2101.
<!-- 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/2190)
<!-- Reviewable:end -->
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.
Add warning about Python 2.7.11 bug to FAQ
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [x] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [x] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
[Please explain **in detail** why the changes in this PR are needed.]
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
There is a bug in vim with Python 2.7.11 on Windows. Adding information in the FAQ.
This is a modification of this pull request: https://github.com/Valloric/YouCompleteMe/pull/2122.
<!-- 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/2128)
<!-- Reviewable:end -->
Update vim documentation with html2vimdoc
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [x] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [x] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
Regenerated vim documentation with html2vimdoc.py to match README.md.
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
<!-- 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/2196)
<!-- Reviewable:end -->
Update go installation details to match others
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [x] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [x] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
The golang details in the README are different than details for other additional languages. Adding a link to the golang download page and updating the wording makes the languages look the same.
[Please explain **in detail** why the changes in this PR are needed.]
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
<!-- 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/2193)
<!-- Reviewable:end -->
[READY] Fixes for multi-byte errors
# PR Prelude
Thank you for working on YCM! :)
**Please complete these steps and check these boxes (by putting an `x` inside
the brackets) _before_ filing your PR:**
- [X] I have read and understood YCM's [CONTRIBUTING][cont] document.
- [X] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
- [X] I have included tests for the changes in my PR. If not, I have included a
rationale for why I haven't.
- [X] **I understand my PR may be closed if it becomes obvious I didn't
actually perform all of these steps.**
# Why this change is necessary and useful
There are a number of recent errors with unicode (most of which caused by the server, see PR https://github.com/Valloric/ycmd/pull/455. In testing I fixed a number of client-side tracebacks also.
This is by no means a comprehensive set of fixes for the client - I have simply fixed those that I came across in testing.
Summary:
- fixes for errors when typing in c-sharp files due to the completion done handler
- fixes for FixIts to apply correctly with multi-byte characters
- fixes for unicode characters in return from the omni completer
[cont]: https://github.com/Valloric/YouCompleteMe/blob/master/CONTRIBUTING.md
[code]: https://github.com/Valloric/YouCompleteMe/blob/master/CODE_OF_CONDUCT.md
<!-- 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/2108)
<!-- Reviewable:end -->