极客研究所极客研究所

Use LazyVim elegantly on Macos

3 分钟阅读技术分享

Welcome to my blog! What I want to share today is how to use lazyvim as your IDE on the mac platform.

0x01. Installation

Before staring the discuss of today's topic, you need to install neovim firstly by command as follows:

brew install neovim

Then, let's start to use lazyvim to turn neovim into an IDE quickly.

The official document link is as follows:

https://www.lazyvim.org/

Through the official documentation, you can quickly get started (if you have some basic knowledge of vim)

  • Firstly, Make a backup of your current config files:
# required
mv ~/.config/nvim{,.bak} 
 
# optional but recommended
mv ~/.local/share/nvim{,.bak}
mv ~/.local/state/nvim{,.bak}
mv ~/.cache/nvim{,.bak}

If you are using neovim for the first time, the file~/.config/nvimshould not exist.

  • Clone it

    git clone https://github.com/LazyVim/starter ~/.config/nvim
  • Remove the .git file to own your repo

    rm -rf ~/.config/nvim/.git
  • Start Neovim!

    nvim

    lazyvim_GUI

Now, We successfully installed our lightly IDE !!

0x02. Configuration Files

First of all, we need to make it clear that the configuration file in lazyvim provides two modes: single file and multi-file`,

I won’t go into too much detail about the two here.

Next, I will use an example to show how to make lazyvim more useful through the configuration file. Here I will use a reference case:

https://zorchp.github.io/tips/%E5%AE%9A%E5%88%B6Neovim%E7%9A%84%E4%B8%80%E9%94%AE%E7%BC%96%E8%AF%91%E8%BF%90%E8%A1%8C%E5%BF%AB%E6%8D%B7%E9%94%AE/#fn:1

You can open the neovim configuration file in this way:

nvim ~/.config/nvim/lua/config/lazy.lua

Here you can see that the configuration file entry for multi-file configuration is lazy.lua, Here I will demonstrate how to quickly compile and run a single Python file using the shortcut F7

PATH

Here I will demonstrate how to quickly write and run a python file.

Firstly, we open the python script we want to run through nvim

codeimg

We have already written the configuration file. Here I press F7 to see the running result of my python file.

result

At this point, this brief introduction is complete. ^_^