-
Notifications
You must be signed in to change notification settings - Fork 55
Diagnostics improvements + other tweaks #106
base: master
Are you sure you want to change the base?
Conversation
* `shell=True` means arguments are passed to the *shell* process, rather than RTags. * This breaks `get_diagnostics`, because `rc` just gets a blank list of arguments.
* Add `rtags#DiagnosticsAll` function (default keymap `rD`) to show diagnostics for all files in the quickfix list. * Only files that are currently open in buffers will have their gutter updated with `E`/`W` symbols.
* Assume there is always an active buffer. * Echo messages on success/fail for getting diagnostics. * Detect unindexed file "error" from RTags and handle it as if it was a non-zero exit code.
* Add automatic diagnostics for files: - Enabled by default, toggled using `g:rtagsAutoDiagnostics`. - Relies mostly on `CursorHold` event, rather than any clever async/polling. - Use nice title in location list - dual use as a tag to determine whether to update list at top of stack or create a new one. * Show current line's diagnostic message in message window. * Add support for RTags fixits - Applies only to current buffer. - Opens loclist with list of fixits applied. - Default keymap `<Leader>rx`. * Support preferring omnifunc for cpp filetypes - Preferred by default, toggled using `g:rtagsCppOmnifunc`. - Otherwise sets completefunc, but still only if it's available to be used. * Improve rendering of diagnostic gutter signs. - Make the background of the sign "transparent" (i.e. match the background of the sign column). Took the algorithm from vim-gitgutter, just converted to python. - Keep a record of placed signs and only unplace those when updating diagnostics, so we don't splat other plugins. * Improved error messages. - Jump to definition/symbol/etc will notify if file is not indexed. - Show errors if rc returns no valid content. * Improved completion popup text to include parent and signature (i.e. class and function with arguments). * Support logging rdm output to a file if `g:rtagsAutoLaunchRdm` is used. - Defaults to /dev/null. Set path using `g:rtagsRdmLogFile`. * Improve python logging - Don't use root logger, so we don't splat config of other plugins. - Include timestamp and log level in messages. * Group buffer related commands and events into a `Buffer` class. - Maintain a cache of `Buffer` objects wrapping vim `buffer` objects, keyed by buffer number, and periodically lazily cleaned of wiped-out buffers. - Get the RTags "project" used for the current buffer, for use in determining if the index has been updated since last checked. - `Buffer.on_idle` is triggered on `CursorHold` autocmd to update the diagnostics or reindex the (dirty) buffer. * Wrap quickfix/gutter sign RTags diagnostics using `Diagnostic` class, with convenience methods to convert from/to rtags/quickfix+signs. * Wrap RTags project in `Project` class, with method to determine if it has been updated on disk. * Fix utf8 encoding when sending buffer contents to rc over stdin in python 3.5+. * Handy util function to get string output of a command (as opposed to result of evaluating an expression) `rtags#getCommandOutput`.
* RTags returns the last used project if given a blank filename, but we want no project in this case.
* Was being sorted with errors at bottom, for some reason. * Add error `nr`, which shows up in the qlist, and is maybe useful for navigation. * Revert error `type` to a choice of "E" or "W", since "F" shows up as a single character, rather than a word, unlike "E"=>"error" and "E"=>"warning". * Append "FIXIT" to the end of error messages for errors with a fixit available.
* In particular, this allows support for filenames with spaces. * Also removed some debug logging spam.
* "0" is truthy, so `int(` it.
* Stop linter complaining
* Missed that one.
* Add error message displayed to user when no jump to symbols found. * Log vim and python to same file. * Default log file to vim `tempname`. * Add timestamp to vim logs, like python, and add a tag to show whether the log comes from vim or from python. * Rename rdm log file var to be in line with standard log file var. * Remove some of the more spammy logs.
* Try to include more relevant info, such as function signatures and Doxygen docstrings.
* `keys()` in python3 returns an iterator, so it's not safe to delete items whilst iterating through them. * So take a copy and iterate over that.
* File name is no longer determined within python, it's an option, so use that.
* Add regular polling for updated diagnostics, with interval configured by `g:rtagsDiagnosticsPollingInterval` (set to <=0 to disable). * Move auto launch rdm, python init and autocmd definitions to bottom of `rtags.vim` file, so all functions are already defined by the time they are called. Just good practice, and needed for the new `Poll` call.
* Don't re-use `id_` variable, we still need it!
* Maybe useful if e.g the user creates a project during a vim session.
* The rtags "project" file doesn't always update when files are re-indexed. * But some files in the project's directory do. * So find the most recently updated file/directory and use that file's modification time as the project's last updated time. * If the project has been deleted/moved then we're in a bad state, so reset internal caches of diagnostics etc in that case.
@feltech It appears you've put a lot of effort on this pull request -- it really looks excellent work. I'll try it and give some feedback. |
Haven't been able to test on my workstation. Vim is compiled to support only python2 and sadly most plugins I use work only with python 2 -- so recompiling for python 3 support will kinda make my system not really usable for developing. Do you have plans, @feltech , to also support python2? |
Hey, thanks for taking a look. I'll try to find some time to ensure it's python2 compatible. I've also done some follow-up work that I'm yet to PR, since it's based on this stuff, so it would be nice to get this reviewed. |
In fact @feltech I was mistaken thinking that your pull request isn't Python 2 compatible. After paying attention to the errors I received, I was able to make it work with a couple of tweaks in your code and it works pretty ok so far. I'll open an issue on your side of things regarding those tweaks. |
I did some testing with this (rtags 2.33) and saw some minor issues;
Note: If it matters, I was running with this branch rebased on top of the current master. |
Background
vim-rtags is the only vim plugin I could find that has the killer "rename symbol" feature for C++, as well as other great features, e.g. class hierarchy. However, diagnostics and completions were nowhere near as friendly as YouCompleteMe and ALE.
Because of the aforementioned two plugins, I already had two clang builds of my project(s) going on at any one time, and with vim-rtags that made three, which is just plain wasteful. vim-rtags was close to replacing all three with a single solution, so I set about adding some tweaks here and there. It's culminated in quite a refactor, especially for the python code (which I am much more familiar with than vimscript).
Highlights
<leader>rx
. Errors with fixits available are marked in the sign column byFx
and suffixed in the diagnostics lists by[FIXIT]
.omnifunc
by default. This allows for trivial compatibility with YouCompleteMe by simply disabling their built-in cpp completion.--diagnostics-all
via<leader>rD
, to show all errors for the entire project.Fixes
shell=True
for python 3.5+ subprocess, sinceshell=True
means arguments are passed to the shell process, rather than RTags.subprocess
rather thansplit
ing a string, which is better for e.g. filenames with spaces.Tweaks
tempname
s by default.Misc
g:rtagsAutoDiagnostics
,g:rtagsDiagnosticsPollingInterval
,g:rtagsCppOmnifunc
,g:rtagsRdmLog
.