Skip to content
This repository has been archived by the owner on Feb 8, 2024. It is now read-only.

Print specific errors when color_coded.so fails to load #170

Open
saristov opened this issue May 31, 2018 · 1 comment
Open

Print specific errors when color_coded.so fails to load #170

saristov opened this issue May 31, 2018 · 1 comment

Comments

@saristov
Copy link

saristov commented May 31, 2018

I recently had an issue with my build environment, which lead to badly build color_coded.so library which failed to load. While the issue itself was more or less trivial to fix after the exact cause of the problem was found, the default plugin behavior was not friendly, all that was given was "color_coded unavailable: you need to compile it (see README.md)".

I suggest the pcall invocation to be changed to include the error message and the message printed on failure. I made "quick and dirty" local change, but I believe, it could be better. My changes are:

diff --git a/autoload/color_coded.vim b/autoload/color_coded.vim
index 02e6359..bf6f62e 100644
--- a/autoload/color_coded.vim
+++ b/autoload/color_coded.vim
@@ -42,13 +42,14 @@ function! color_coded#setup()
   " Try to get the lua binding working
   lua << EOF
     package.cpath = vim.eval("$VIMHOME") .. "/color_coded.so"
-    local loaded = pcall(require, "color_coded")
+    local loaded, err = pcall(require, "color_coded")
     if not loaded then
       vim.command('echohl WarningMsg | ' ..
             'echomsg "color_coded unavailable: you need to compile it ' ..
-            '(see README.md)" | ' ..
+            '(see README.md) ' .. package.cpath .. '" | ' ..
             'echohl None')
       vim.command("let s:color_coded_valid = 0")
+      print(err)
       return
     else
       local version = color_coded_api_version()

@jeaye
Copy link
Owner

jeaye commented May 31, 2018

Thanks for the detailed ticket! I'm glad you were able to sort out your issue with a minimal change to the code. I think, in general, this is a pretty good proposed change, but I think we can redirect the error output to a color_coded.log, perhaps. Are you up for making a PR with the above changes, except just printing the error output to a file?

From there, we'll just need to update the readme to mention the error log file. You could include that in the PR or I could do it.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants