Vim and Haiku

Vim is my preferred text editor environment. I’d love to get autocomplete working in vim, either coc or ycm. Both have the requirement of a working py3 enabled vim. But I see that at least one Haiku user has overcome this hurdle. Getting either installed vim-natively currently fails.

I would use the ycm recipe in ports, but things have changed since that was written. What is the current way of getting completion working in vim for those setting up a new environment from scratch and not having an older environment that they have been using for several years? Should I be using x86 as opposed to x86_64?

Why not try to fix the recipes?

1 Like

I’d love to, but I’m in a bit above my head. Which is exactly the intent of my query. I’m not sure where to start. But I will will look further into it as I have time. And I’d also want to not duplicate work if someone is working on this.

Also, installing vim plugins is best done natively within vim. According to @PulkoMandy, this recipe (ycm) was a hack to simplify the use of this plug in in the short term. It was meant for this recipe to be deprecated once native installation was easily possible. Things have changed in the YouCompleteMe code that possibly make this possible since the recipe was created. So the recipe possibly is no longer relevant.

As far as getting the vim recipes working with python and python3, it seems some code wizardry that is above my level is needed. But I will keep plugging away at it as much as I can. I’d like to dissect what others apparently have working to build my experience to get the rest working. But I haven’t yet gotten working what others say they use. Which is why my question about should I revert back to x86_gcc2 or is there something I’m missing?

What? Why?

Why would you manage your vim plugins manually when we have a great package manager that can handle updates for you? Sounds like a very strange idea to me. Please keep the recipe (and update it if you can).

On x86_64, you shouldn’t have this much problems, YouCompleteMe can be set up normally, with a fully python3 environment.

The problem I had at the time, that made the recipe a bit complicated, is that vim for 32bit Haiku is built with gcc2, and there is no Python3 library for gcc2. So, vim itself runs with Python2 scripting, but YouCompleteMe server runs with Python3. I had to convince YouCompleteMe code that this is a valid setup, even if the YouCompleteMe developers wouldn’t expect it.

This is the “temporary hack” that I mentionned. The proper fix would be:

  • Make sure to compile vim with gcc11 and with python3 support, on all architectures
  • Simplify the YouCompleteMe recipe to be fully Python3 as inteded by YouCompleteMe developers

Then there should be no “clever” hacks anymore, the recipes will be a lot simpler and more maintainable.

4 Likes

This highlighted some shortcomings in what I was trying to do. I will give it another shot later.

While I love our excellent package manager, handling vim plugins natively in vim makes more sense to me. Especially from the standpoint of using several operating systems and portability of the vimrc. I may be missing something here as I’m still trying to get any solution to work.

1 Like

That’s fine for simple plugins that are purely implemented in vim. But youcompleteme is not built like that. There is only a small part of it running inside vim, that starts a separate server written mostly in python and uses sockets to communicate with it. The server also uses libclang, so a part of it is written in C++. This is all compiled when you install or package the plugin. So you can’t carry that part from one machine to another, especially not accross different operating systems.

1 Like

I know this is an old thread… but just wanted to leave a comment about my attempt to get youcompleteme working on R4 release with vim.

I’m new to haiku, but was able to get haikuports installed and got youcompleteme (ycm) to compile. since vim 8.2 now has python3, I removed all references to python2 in the ycm recipe. I also had to add a cp -r command at the bottom to copy over the ycm thirdparty directory as it was complaining about not finding things.

So, ycm loads into vim, but then it looks like python errors complaining about stuff. guessing it couldn’t startup the ycm server.

the version of vim that ships with R4 looks to be statically linked with python3.7? the github page for ycm says python3.8 or higher is needed. I therefore recompiled vim with python3, and it dynamically pulls in python3.9, the default on my system.

but, even with this, ycm failed to load.

Not sure what else to try. Any ideas and I’d be happy to try out more things. kind of over my head now, being new to haiku.

I think when the server fails to start, it should log some things to files in /tmp. Have you looked there if there is any useful info?

It’s been a while since I last tried it. Your steps so far seems correct to me, it would be great if you can share the updated recipes :slight_smile:

sure, would be happy too share them… kind of new to the scene here, what’s the best way?

as for the logs, I’ll take a look.

thanks!

1 Like

The ideal way is to send a pull request to GitHub - haikuports/haikuports: Software ports for the Haiku operating system.

But if that’s too complex (git isn’t really the simplest tool if you don’t know it), just share the recipe files here and we’ll take care of them :slight_smile:

1 Like

looks like I didn’t have requests-futures python module for python3.9 installed. requests-futures recipe was out of date, updated it and submitted pull request.

so, no ycm errors… youcompleteme however says unable to start server. still investigating.

2 Likes

Hello,

I have fixed various problems with the recipes in haikuports. The ones you had already fixed, but also, and I think that’s the problem you were getting in the last state, the libclang library was missing from the llvm_libs package.

I have now fixed that and… now the youcompleteme server is crashing Python when it starts :frowning:

1 Like

ya, I kind of gave up on youcompleteme… figured I’d eventually invest some time looking into neovim / lunarvim and see how / if their LSP is better / easier to port?

Between the “vims” I prefer neovim when not using Haiku. As far as I know we don’t yet have it working in Haiku.

Though I don’t know if neovim would be up for an “official” Haiku port as a lot of the cruft they removed from the original vim code was “weird ports” like BeOS. But maybe Haiku is not quite so obscure as BeOS is now, and a lot of our POSIX and library support is much better, so there is likely less “port” code needed.

Anyhow I found this Gist from someone else in their experience trying to port it to Haiku. Seems like the next step is more work on libuv, and some of that may have been done in the meantime (the gist was last updated in October 2017):

Though this is a project that is probably more difficult than trying to get YouCompleteMe to work in vim. I will probably try to look at porting neovim next time I work on Haiku things, though that may not be any time soon.

1 Like

I vaguely recall someone posting a working Neovim screenshot on IRC not long ago. Forgot the nickname though.

I wonder how big the patch would be. Haiku patch set for Vim was quite monstrous (thankfully all accepted upstream). It even received quite a lot of Haiku fixes from the Vim community as well.

It was “monstrous” because it included a complete native GUI. Which we didn’t even write ourselves: this used to be in Vim upstream in version 5 or 6.something, then was removed from there and moved to a patchset at haikuports, and then was upstreamed to Vim again. The patch also included many updates to help files, and so on.

But there were, I think, not that many changes to the core of Vim itself?

Yes, the GUI and its integration were touching a lot of places (around 6k loc). Minus that, middle sized I guess. Vim is one of the software that currently has excellent Haiku support thanks to the previous authors.

The GUI code can be modernised though, if someone is up to it, feel free to send patches directly to the Vim upstream. Vim developers are quite receptive.

1 Like