MacVim is a port of the text editor Vim to Mac OS X that is meant to look better and integrate more seamlessly with the Mac than the older Carbon port of Vim. MacVim supports multiple windows with tabbed editing and a host of other features such as: bindings to standard OS X keyboard shortcuts (⌘-Z, ⌘-V, ⌘-A, ⌘-G, etc.). My Vim comes with the OS X system and is located at /usr/share/vim/vim73. According to the instruction, I created a folder as /.vim and unzip the source file into directory /.vim. Then I create a file.vimrc at / with the following content: REQUIRED. This makes vim invoke LaTeX-Suite when you open a TeX file. Filetype plugin on.
From: http://stackoverflow.com/questions/21012203/gvim-or-macvim-in-mac-os-x
- Step 1. Install homebrew from here: http://brew.sh
- Step 1.1. Run
export PATH=/usr/local/bin:$PATH
- Step 2. Run
brew update
- Step 3. Run
brew install vim && brew install macvim
- Step 4. Run
brew link macvim
You now have the latest versions of vim and macvim managed by brew. Run brew update && brew upgrade
every once in a while to upgrade them.
This includes the installation of the CLI mvim
and the mac application (which both point to the same thing).
I use this setup and it works like a charm. Brew even takes care of installing vim with the preferable options.
System: macOS Mojave 10.14.6
vim version: 8.1 (higher than 7.4.1578 and supports Python 2 or Python 3)
CMake is a cross-platform project management tool. It can be obtained directly through brew
Vundle is an automated vim plug-in manager. Due to version updates, the configuration of Vundle is no longer consistent with half of the tutorials given online. Reference to Vundle's Official Documents To install Vundle, you can use the following commands
Once the download is complete, you can use Vundle to download and manage other plug-ins. First, specify the plug-in to use Vundle management in ~/.vimrc
The parameter after the Plugin command is the address of the plug-in to be managed at github. Once saved, open vim and run the command
Mac Install Vim-plug
Vundle checks whether these plug-ins are installed, and if not, it automatically downloads and installs them to github.
YouCompleteMe is also a plug-in, so it can be installed through Vundle. The difference is that
- YCM has a large volume and slow download speed. It's better to find a place to visit github fast to download.
- YCM needs to be compiled, so it will report an error after downloading, regardless of him.
Switch to YCM's download directory to run the installation script
If the C family needs to be semantically complemented, use parameters
If you're lucky enough, it should be ready. But in general, it's not possible (the hardest thing in history to install a plug-in is not for nothing). So YCM Official Documents The method of full manual installation is given in this paper.
1. Download YCM
This step can be done by pulling the git warehouse either by Vundle or manually.
It should be noted that many third-party warehouses are introduced in YCM warehouse. In especial
In this warehouse, the blogger did not succeed in two reloads (I don't know if this is the design). According to the official website, the installation of cregex is optional, and it may not matter if it is not downloaded. But after all, all the big heads are downloaded, and that's not bad.
2. Download libclang
This step is only necessary for C family semantic completion and can be skipped by unnecessary users. Hangout meet download mac. Direct access llvm official website Download llvm binary file
YCM officially requires llvm version not less than 8.0.0, but the maximum version 8.0.1 currently does not have macOS version, so you have to download this version first. If you have the latest version in the future, it is better to download the new version, so as not to recompile because of YCM updates.
Downloading precompiled llvm binaries is YCM's official recommendation, but using native llvm is also feasible
Because the blogger's network is so moving that it can't survive, and the result is unknown. Installed buddies can try.
Backup!!!
The two steps mentioned earlier are probably the longest in the installation process. Therefore, before proceeding with the installation, it is better to backup the downloaded files, so as to avoid the subsequent installation failure and re-download. Bloggers put downloaded files on Baidu's web disk
Links: https://pan.baidu.com/s/1y05NTT0PKpiDe-PXCKRs3w Password: zd3o
Compressed after about 600 MB, you can consider the speed of selective download.
Compile ycm_core
Next is the core of compiling YCM. First, you need to put the decompressed llvm in the ~/ycm_temp directory.
Then switch to the compiler directory
Start compiling
If it works properly, your YCM should already be available. Deleting the temporary path created above will not affect YCM work
Compile regex
This step is optional in order to speed up the analysis of regular expressions. The compilation process is similar to that above.
After installation, YCM needs to be configured. If you use Vundle for management (YCM is in the ~/.vim/bundle/ directory), please confirm whether there is ~/.vimrc first.
Note that YCM declarations should be placed between vundle begin () and vundle end ().
Then I changed the location of the file. ycm_extra_conf.py, which I found in the YouCompleteMe / directory when I installed it. Estimation is another change in the process of renewal. In short, find the file and define it after the import statement
The annotated part is original. As you can see here, we define a list of flags as the return value of the FlagsForFile function. This list acts as a parameter following the gcc command. Look first at a series of values of - isystem, which contain paths that the compiler searches for when # include <..>. Although they are roughly the same, the paths of different computers may be slightly different and can be queried by command.
Notice that there is a line # include <..> search start here: the next few lines are the information we want.
After editing. ycm_extra_conf.py, you need to modify ~/.vimrc. Write after YCM's Plugin statement
It is equivalent to setting the newly modified file to the global YCM configuration. So YCM should be able to work. Open a source file at will, and the completion option will pop up automatically when the identifier is entered. If there is no response, or if you prompt The ycmd server SHUT DOWN on the bottom command line like a blogger, you need a little more work.
But if you install it successfully, congratulations, your vim already has IDE-level auto-completion. If necessary, it can also be configured in ~/.vimrc
According to the blogger's three-day experience of installing YCM, the main reason why this plug-in is difficult to install is that the download speed is slow. If you download the YouCompleteMe repository and llvm binary in advance, it will not be slow to install (bloggers will run out within five minutes of the last reload). So it's not difficult to reinstall as long as the backup is done before installation. Now let's talk about the problems I encountered during installation.
Mac Vim Install Youcompleteme
vim flashback, report python's Momsory Error
This problem occurred after I first used Vundle to install YCM. At that time, everything went amazingly well, Vundle downloaded YCM in less than half an hour, and reported an error Memory Error. But at that time, I thought that this mistake was the 'normal' mistake in the legend. I didn't care about him. When a set of installation process came down, I found that my vim was no longer in use.
Later, I found that the Vundle I installed was an old version, and all the commands I used were Bundle'Valloric/YouCompleteMe'. It may be compatibility issues and so on. In short, vim triggers MemoryError when it handles call vundle#rc(). Finally, delete the Vundle and reinstall it.
The ycmd server SHUT DOWN .. Unexpected exit code -11 ..
According to the prompt to check the log found to be empty, searched the Internet for a long time and no one said - 11 code corresponding to what the problem is.. Maybe it's Unexpected. So the blogger used the omnipotent remedy.
Re-install. However, I gave up after two reinstallations. Generally speaking, installation errors are not so frequent. Later, I saw the ideas provided by netizens on a website.
- Use the command: YcmDiag to get specific information
- Comment let g:ycm_confirm_extra_conf=0 in ~/.vimrc to confirm compilation
The first method is actually equivalent to viewing the log, except that the log does not record information, and the command actually returns an error that the built-in completion function cannot recognize the file type. It's also because of this error message that I suspect the installation of llvm (install.py was used all the time before, and I didn't think that automatic downloading would cause problems).
The second method is a little more complicated. Normally, after entering vim, YCM will ask at the bottom command line if a. ycm_extra_conf.py file is loaded unless this function is disabled in ~/. vimrc (that is, the function of the command above). So if compiled properly, there should be similar queries. Even if there is a mistake, it should collapse after asking. But the blogger's VIM prompts server shutdown as soon as it enters, so it's doubtful that there's something wrong with the compilation process.
As a result, reinstallation is necessary, but it's no longer reliable to install with scripts, so I chose to install manually. It has to be said that official documents should be taken seriously, even if there are problems after installation, it is generally not fatal.
Python version
The most common question asked online is the inconsistency of versions. There are two main inconsistencies: Python version and llvm version. Since llvm is downloaded manually from the official website, there is no such problem. As for the Python version, bloggers haven't figured out what the problem is.. But as a result, ycmd server shutdown again. This time, instead of Unexpected, it reminds me that the Python version used at compile time is different from the Python version used at run time, and that the installation path of Python 2 needs to be given in ~/.vimrc. So there's a sentence like this.
As mentioned above, a flags list is added when modifying ~/.vim/bundle/YouCompleteMe/.ycm_extra_conf.py. The - isystem option in this list specifies the search path for the system header file. For the header file inside the project, there is only the phrase'-I','.'. If you use header files that are not in this directory in your project, you also need to modify this file. But obviously this is inefficient. Therefore, it is better to copy a configuration file to the root directory of the project source code and add the project header directory to the configuration file. Because YCM searches for. ycm_extra_conf.py first for the current directory, then one by one for the parent directory, and finally for the global configuration file. Therefore, the configuration file of the project root directory can overwrite the global file. This is equivalent to specifying a separate configuration for each project, without polluting the system settings.
Posted by cyberrate on Tue, 13 Aug 2019 22:24:20 -0700