diff options
author | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-10-20 11:13:54 +0900 |
---|---|---|
committer | Shougo Matsushita <Shougo.Matsu@gmail.com> | 2016-10-20 14:48:25 +0900 |
commit | 981aedb97b0bc75331eccddef5794c8e3899b12d (patch) | |
tree | 7d5a3093eca110f244185092b9ff85a15908f210 /rplugin | |
parent | e28d5190296e0768d7d2cf28be3007687fb4b2e0 (diff) | |
download | deoplete.nvim-981aedb97b0bc75331eccddef5794c8e3899b12d.zip |
Improve debug messages
Diffstat (limited to 'rplugin')
-rw-r--r-- | rplugin/python3/deoplete/util.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/rplugin/python3/deoplete/util.py b/rplugin/python3/deoplete/util.py index ab12a9c..cb4ab8e 100644 --- a/rplugin/python3/deoplete/util.py +++ b/rplugin/python3/deoplete/util.py @@ -3,11 +3,11 @@ # AUTHOR: Shougo Matsushita <Shougo.Matsu at gmail.com> # License: MIT license # ============================================================================ + import os import re import sys import glob -import json import traceback import unicodedata @@ -94,16 +94,19 @@ def import_plugin(path, source, classname): def debug(vim, expr): - try: - json_data = json.dumps(str(expr).strip()) - except Exception: - vim.command('echomsg string(\'' + str(expr).strip() + '\')') + if hasattr(vim, 'out_write'): + string = (expr if isinstance(expr, str) else str(expr)) + return vim.out_write('[deoplete] ' + string + '\n') else: - vim.command('echomsg string(\'' + escape(json_data) + '\')') + vim.call('deoplete#util#print_debug', expr) -def error(vim, msg): - vim.call('deoplete#util#print_error', msg) +def error(vim, expr): + if hasattr(vim, 'err_write'): + string = (expr if isinstance(expr, str) else str(expr)) + return vim.err_write('[deoplete] ' + string + '\n') + else: + vim.call('deoplete#util#print_error', expr) def error_tb(vim, msg): |