Code Monkey home page Code Monkey logo

Comments (19)

melonaerial avatar melonaerial commented on July 17, 2024

I want to see something like this!

vim_cpp_highlight_good

So as you cna see on this screenshot all variables of class highlighted with special color. That's look good. So how can I don it with you service ? For that look in vim I've used color_coded plugin. But you plugin working asynchroniously that sounds great, because color_coded doesn't work in such mode.

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Hi @melonaerial,

I think that you may not be using yaflandia colorscheme and that is why you don't see the effect of syntax highlighting. The reason you have to use that particular colorscheme is because standard colorschemes do not support displaying C/C++ symbols at that granularity (i.e. enums, enum values, local variables, functions, classes etc.). You have two choices here:

  1. Switch to the yaflandia colorscheme to see the effect of syntax highlighting instantly.
  2. Use a colorscheme of your preference and tweak it a little bit to make it compatible with Yavide syntax highlighting service. For example, following file, cpp_syntax_highlight.vim, defines additional symbols which syntax service will understand (and generate) and those simply need to be mapped to particular colors in a colorscheme you want to use. See how yaflandia colorscheme does it. It's trivial ... you just have to pick the colors for the given symbols: yaflandia.

However, under the hood Yavide syntax highlighter utilizes ctags to generate those symbols. ctags actually isn't anymore the best solution for that purpose (even though it mostly does a decent job) but particularly it does not cope well with modern C++ code. Hence, my wish is to replace ctags with clang based approach which is, for example, used by color_coded plugin but I haven't had much time recently to update the implementation.

Developing the async processing framework was what I was mostly focused on. This was my prio number one as without this framework implementing and integrating anything into the environment simply does not make any sense. Blocking the main UI thread while running the indexer/syntax highlighter/build/formatter/etc. was simply not an option.

from yavide.

melonaerial avatar melonaerial commented on July 17, 2024

Hello @JBakamovic ,
Thanks for such detailed answer. Yes, blocking UI thread is not an option and that's where cool that you have made such big work on async service. That's cool. But for colorsheme, I'm already using yaflandia from your repo, so it is default configuration of yavide and yaflandia is in default config. Maybe ctags doesn't work or something on my computer. Have can I see some debug information about running of Syntax hightlighting service ?

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Hi @melonaerial,

I've tried out your test project on my machine and syntax highlighting seems to be running fine. Did you forget to import the project? You need to create a yavide project in order to get all the services running. Handling projects is easy as it can be and amongst other things it is described in usage document. Following is a small excerpt from that documentation:

  1. <Ctrl-s>n Create new project
  2. <Ctrl-s>i Import project with already existing code base
  3. <Ctrl-s>o Open project
  4. <Ctrl-s>c Close project
  5. <Ctrl-s>s Save project
  6. <Ctrl-s>d Delete project

So, you can try to create a new yavide project by importing already existing code base (see 2.).

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Hi @melonaerial,

With commit 9d44c4b I have released an update of syntax highlighting service. It is now using a libclang based back-end. You should now be able to get more satisfying results. See docs for more details.

You can give it a try if you feel like and let me know how it went :)

P.S. Don't forget to update the colorscheme as well by running cd <yavide_install_dir>/colors/yaflandia && git pull. It's not automated yet :/

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

Im having the same problem both in Windows 10 and Lubuntu vm version.

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Did you try out the steps above, i.e. import a project? You will not get any services running until you create a project context.

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

I created a test project

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

http://gph.is/2rXq7g8

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Hm, in the video I can see that the file you're editing is test.cpp but I cannot see that file in the file-explorer on the left-hand side. Is this file part of that directory? If not, then it is not going to work like that.

Otherwise, you can attach the log which you can find under /tmp/YAVIDE_server.log so I can have a look what is happening.

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

The file exists in the directory but does not appear in nerdtree.
directory

YAVIDE_server.log - there seems to be an error

[INFO] [yavide_server.py:124]         yavide_server_run(): Starting a Yavide server ...
[INFO] [yavide_service.py:17]                  __init__(): Yavide instance: YAVIDE
[INFO] [yavide_service.py:18]                  __init__(): Actions: {0: <bound method SourceCodeModel.__startup_request of <services.source_code_model_service.SourceCodeModel instance at 0x7fb58ffe3758>>, 1: <bound method SourceCodeModel.__shutdown_request of <services.source_code_model_service.SourceCodeModel instance at 0x7fb58ffe3758>>, 2: <bound method SourceCodeModel.__request of <services.source_code_model_service.SourceCodeModel instance at 0x7fb58ffe3758>>}
[CRITICAL] [yavide_server.py:99]          handle_exception(): Uncaught exception
Traceback (most recent call last):
  File "/opt/yavide/core/server/yavide_server.py", line 128, in yavide_server_run
    YavideServer(msg_queue, yavide_instance).listen()
  File "/opt/yavide/core/server/yavide_server.py", line 16, in __init__
    0x0 : SourceCodeModel(self.msg_queue, self.yavide_instance),
  File "/opt/yavide/core/services/source_code_model_service.py", line 14, in __init__
    self.parser = ClangParser()
  File "/opt/yavide/core/services/parser/clang_parser.py", line 71, in __init__
    self.index = clang.cindex.Index.create()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 2218, in create
    return Index(conf.lib.clang_createIndex(excludeDecls, 0))
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 141, in __get__
    value = self.wrapped(instance)
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3575, in lib
    lib = self.get_cindex_library()
  File "/usr/local/lib/python2.7/dist-packages/clang/cindex.py", line 3606, in get_cindex_library
    raise LibclangError(msg)
LibclangError: libclang.so: cannot open shared object file: No such file or directory. To provide a path to libclang use Config.set_library_path() or Config.set_library_file().

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

I'll start writing the instructions for Windows once I get it working in the vm.

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

You're missing a libclang.so dependency. It should have been installed with the install.sh script though. I am not sure why is that not the case but nevertheless you can install this dependency very easily by yourself. Not sure which distro are you running, but instructions to install it would be distro-specific and are usually straightforward.

Let me know if that fixed the issue for you.

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

Have not found the solution. What distro are you running it in?

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

Nevermind, I got it to work. I had to edit the cindex.py file in the clang python directory.

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

I am running Fedora almost exclusively and I haven't experienced such issues. So, if I understood you well, you had libclang.so installed on your system but cindex.py was not able to set the right path to it? Which distro are you running? Can you please share what modification you did so others having the same issue can benefit from it?

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

OS: Lubuntu and Ubuntu in Windows 10

First I tested this code in the python shell with the different paths until I did not get the error:

import clang
import clang.cindex
clang.cindex.set_library_file( {DIRECTORY} )
index = clang.cindex.Index.create()

In my case the one that worked was: /usr/lib/x86_64-linux-gnu/libclang-4.0.so.1
Then I hardcoded the file path in the cindex.py file located in /usr/local/lib/python2.7/dist-packages/clang/cindex.py in this line.

from yavide.

iperez319 avatar iperez319 commented on July 17, 2024

Although it is not autocompleting the algorithms standard library

from yavide.

JBakamovic avatar JBakamovic commented on July 17, 2024

Hm, auto-completion is handled via clang_complete. I would expect that it should be working out-of-the-box for STL but if not, you can edit .clang_complete file which is located in the root of your project directory. This file should include paths to system include directories as well as include directories specific to your project: i.e. -I flag with corresponding paths that you would normally pass to your compiler.

With respect to libclang.so path problem, I believe that the culprit is that libclang library is not part of your system dynamic linker cache configuration and that is the reason why cdll.LoadLibrary('libclang.so') is failing for your system. You can easily check that by running the following command: ldconfig -p | grep libclang.so. I believe the output will be empty in your case. In my case it looks like:

libclang.so.3.9 (libc,x86-64) => /lib64/libclang.so.3.9
libclang.so (libc,x86-64) => /lib64/libclang.so

If my assumptions are right then you will be able to fix the problem by tweaking the LD_LIBRARY_PATH so it includes the directory where libclang library resides. It's a cleaner solution as it does not require you to mess up with the cindex.py.

from yavide.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.