Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make the plugin to be compatible with Python 3.
Squashed commit of the following: commit 0973c5179e504ffbd74a38d6557bb49fe3bf8b5d Author: Hong Xu <hong@topbug.net> Date: Sun Jan 10 00:11:11 2016 -0800 Some minor corrections commit ca17e97 Author: Shunsuke Shimizu <grafi@grafi.jp> Date: Sun Jan 10 15:24:13 2016 +0900 vim 7.3 support by using `py[3]` command instead of `py[3]eval()` function commit c51ae80 Author: grafi <grafi@grafi.jp> Date: Sun Jan 10 14:42:38 2016 +0900 use print_function on python2 commit 401a948 Author: grafi <grafi@grafi.jp> Date: Sun Jan 10 14:33:25 2016 +0900 assure that sys.path is cleaned commit f3bf442 Author: grafi <grafi@grafi.jp> Date: Sun Jan 10 14:22:45 2016 +0900 python3 style print commit 8e05937 Author: Shunsuke Shimizu <grafi@grafi.jp> Date: Sat Dec 26 07:54:49 2015 +0900 Support python3
- Loading branch information
Showing
2 changed files
with
61 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
from __future__ import print_function | ||
|
||
try: | ||
try: | ||
import vim | ||
import sys | ||
except: | ||
vim.command('let l:ret = 2') | ||
raise | ||
|
||
try: | ||
sys.path.insert(0, vim.eval('a:editorconfig_core_py_dir')) | ||
|
||
import editorconfig | ||
import editorconfig.exceptions as editorconfig_except | ||
except: | ||
vim.command('let l:ret = 3') | ||
raise | ||
finally: | ||
del sys.path[0] | ||
|
||
# `ec_` prefix is used in order to keep clean Python namespace | ||
ec_data = {} | ||
|
||
def ec_UseConfigFiles(): | ||
ec_data['filename'] = vim.eval("expand('%:p')") | ||
ec_data['conf_file'] = ".editorconfig" | ||
|
||
try: | ||
ec_data['options'] = editorconfig.get_properties(ec_data['filename']) | ||
except editorconfig_except.EditorConfigError as e: | ||
if int(vim.eval('g:EditorConfig_verbose')) != 0: | ||
print(str(e), file=sys.stderr) | ||
vim.command('let l:ret = 1') | ||
return | ||
|
||
for key, value in ec_data['options'].items(): | ||
vim.command("let l:config['" + key.replace("'", "''") + "'] = " + | ||
"'" + value.replace("'", "''") + "'") | ||
|
||
except: | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters