XVimProject / XVim

Xcode plugin for Vim keybindings
MIT License
5.16k stars 595 forks source link

[Sidetrack] Have anyone tried to fully replace xcode with vim? #1044

Open tflhyl opened 7 years ago

tflhyl commented 7 years ago

Hi sorry if this is not really related to xvim, but I'm just wondering if anyone has fully move away from using xcode to vim for ios project.

Given the future seems to be bleak for this plugin if in the future Apple completely disable the ability to load plugin even on unsigned xcode, i'm seriously considering to work with my xcode projects in vim. I think there should be no issue of building, testing or running on device using command line xcodebuild. The real issue might be autocompletion. I'm looking into this plugin https://github.com/keith/sourcekittendaemon.vim but i'm not sure if it will work well. The other thing is build/project settings editor and adding files to target, which is gonna be very painful to do manually.

Of course, finger-crossed, i hope Apple somehow will unveil vim mode on xcode this wwdc or they improve the extension api so there is hope in making this plugin an extension. Anyway i'd like to thank all the contributors and esp @JugglerShu for this awesome plugin! Honestly i cant imagine having to work with xcode without xvim.

lando2319 commented 7 years ago

There is no compiler to see the results of your code, also you wouldn't have the same autosuggest setup since you wouldn't have direct access to Apple's methods, so you wouldn't be able to peruse the available methods in the same manner.

hamsternik commented 7 years ago

Since last month, I started using emacs instead of vim and I was excited by this text editor. But if we talking about the text editor, I actually can't realize how to fully use emacs or vim as the full-featured development environment. Afaik, it's due for several reasons.

First, it's key binding. Yes, setup your custom keybindings - so easy task for every vim/emacs user, but I can't imagine what you will do when you need to compile your iOS application and then run it on the iPad simulator or with the connected device. Do you have to write commands in the terminal every time or run the script?

The next one - editing build settings. Maybe, someone not afraid to configure them by editing them into the text editor, without any Xcode UI, but I guess, it's not convenient. Or just run Xcode to edit your build configuration. That's silly, as for me.

ps. subscribed, so interesting to listen to another opinion.

keith commented 7 years ago

As the author of the original mentioned plugin, there are a lot of issues with the server that depends on now. One big one is not supporting Xcode workspaces which at least means not supporting most CocoaPods installations.

I've very interested in this topic, and I think with async support in Vim 8, along with the swift support being added to YCM there's a real possibility we can get somewhere with this.

There are a lot of issues that would need to be solved to effectively replace Xcode for general development (assuming you require autocomplete, if not, you can go ahead and use vim-xcode to do pretty much everything else).

A few of the issues off the top of my head:

  1. Indexing, and reindexing. Xcode handles this automatically, but if you're not using Xcode you'd have to handle this.
  2. Generating compiler flags. In order to get reliable completion info from SourceKit (at least for Swift) you'd need to be able to take a foo.xcodeproj and get an array of compiler flags from that. It seems that the compiler flags you pass to SourceKit need to maintain the order from request to request, so if you're interested in a hybrid vim + Xcode workflow, you would need to replicate the ordering to use the same cache (I think).
  3. Related to 2 you need to know per file what the compiler flags are. This can differ if you have multiple targets with different file memberships.
  4. Highlighting and indentation. I have a plugin for this for Swift that works pretty well, but it's definitely not perfect. I think for me this is low on the list of what's required, but that might be controversial.
  5. A good compile, run, debug, logging workflow. I think vim-xcode is a great first step to this, but if you're truly using Vim without Xcode you'd need to be able to easily attach to lldb for debugging, and maybe have another tmux pane for logging (the logging part is pretty much solved with the new os log CLI).

These are just a few quick hits as I've been thinking a lot lately about what is possible here. I'm definitely interested in working on this further to see how feasible it is. If anyone else is interested in this, or knows of any existing efforts out there I'd love to hear about it!

tflhyl commented 7 years ago

@hamsternik i believe building and running the app to device could be done with xcrun xcodebuild with bunch of arguments. i'd imagine we need script that wrap this to make life easier. but @keith makes a good point on the need to attach lldb to debug and logging window which i completely overlook

jerrymarino commented 7 years ago

I've had luck using Vim for Apple SDK Xcode development for the last several years on and off in large scale code bases.

I generally try to stay away from plugins and try to maximize the existing Vim features as much as possible. That being said there's a few tools I use in addition to Vim.

Semantic Vim Support

YouCompleteMe is the main semantic plugin I use and it has worked great for clang based ObjC/C/C++ ( and python, and more ) development. It doesn't have Swift support yet, but I think the first commit is almost ready to land in YCMD. It already supports completion well and diagnostics are almost done.

If anyone is interested in helping manually test it in or give feedback it could be super helpful and your feedback could help me improve it. 🍺

I started SwiftySwiftVim to expose Swift editor facilities over HTTP: the backend for Swift under YouCompleteMe.

For any of this stuff to work in real projects, Xcode needs to generate compiler commands to feed into the tooling. I posted up XcodeCompilationDatabase which is a tool that can generate compile_commands.json as part of the build process.

Searching massive codebases

Xcode's search engine doens't scale with several thousands of files anyways and there is better ways to search.

I use vimgrep ( :vim ) and other basic features to do non semantic searches. Searches need to carefully target subsets of the code or they will be slow - also there's faster search engines like ag.

Building and Running

There is a decent CLI tool for the simulator now which needs a lot of help to replicate what Xcode can do.

I recently posted a shell script to replicate the behavior of CMD-R to run and debug with lldb and view the standard output of the simulator. The script isn't 100% yet.

I'm not sure if it is possible to get right without using Xcode's internal frameworks.

Refactoring

Find and replace abilities can be subbed with vimgrep or even grep on the CLI.

I've had luck doing semantic refactoring with automated tooling based on LibTooling for ObjC code ( i.e. renaming hundreds of methods and data types in several hundreds of files ). This is a serious C++ library that can do refactoring work and more. There isn't a great open source higher level interface to it, yet. I've put up a basic gist of using this in ObjC code. I end up hacking together 1 off C++ programs like that which saved hours grunt work.

Hope that's helpful!