How to Configure Neovim to make it Amazing -- complete tutorial

typecraft
1 Dec 202209:21

Summary

TLDRこのビデオは、Neovimの設定を理解し、Luaで書かれた非常にシンプルで理解しやすい方法で美しくする方法を紹介しています。Vimscriptの理解が難しいと感じていた制作者は、Neovimの組み込みスクリプト言語であるLuaを使って、新しい設定を始めました。Luaのモジュール機能を活用して設定をモジュール化し、Packer.nvimパッケージマネージャーをインストールして機能性を追加しました。さらに、grovboxのカラースキーム、nvim-tree、Telescopeなどのプラグインを追加し、設定をカスタマイズしました。このプロセスは、Luaの機能を最大限に活用し、短時間で素晴らしい設定を実現する手順を説明しています。

Takeaways

  • 📘 ネオビムの設定は、多くのアイデアと慣習があり、理解するのが難しい場合があります。
  • 🛠️ ネオビムは、Luaという組み込み可能な軽量プログラミング言語を標準で備えており、機能型、手続き型、オブジェクト指向型のプログラミングをサポートしています。
  • 📋 ネオビムでは、通常のinit.vimの代わりにinit.luaファイルを使用して設定を読み込むことができます。
  • 🔧 Luaを使用すると、設定をモジュール化し、より使いやすく、理解しやすくなります。
  • 📦 Packer.nvimは、Luaで書かれたネオビムのパッケージ管理システムで、非同期インストールや遅延ローディングなどの機能があります。
  • 🎨 GroveboxカラースキームやNVM、web-dev icons、luolineなどのプラグインをインストールして、ネオビムの外観を向上させることができます。
  • 🔗 各プラグインの設定を個別のファイルにすることで、モジュール化された設定が維持できます。
  • 🌳 Nvim-treeを使用すると、ファイルの閲覧や検索が簡単になります。
  • 🔍 Telescopeは、ファイルやシンタックスハイライトなど、多くの便利な機能を提供します。
  • 🎉 Luaを使用して、短時間で非常に最小限の設定で素晴らしいネオビムの設定を作成できます。
  • 🔜 LSP(Language Server Protocol)については、次の動画で解説する予定です。

Q & A

  • Neovimとは何ですか?

    -Neovimは、Vimのパワフルなテキストエディタの拡張版です。Luaという軽量で組み込み可能なプログラミング言語を内蔵しており、機能型、手続き型、オブジェクト指向型のプログラミングをサポートしています。

  • Luaを使ったNeovimの設定ファイルはどのように作成しますか?

    -Neovimの設定ファイルは、`init.lua`という名前のLuaスクリプトファイルとして作成します。このファイルは`~/.config/nvim/init.lua`に配置されます。

  • Vim設定をLuaでどのように記述するのですか?

    -LuaでVim設定を記述する際には、`vim.g`と`vim.opt`を使用して、VimのAPIを呼び出して設定を行います。例えば、`vim.g.leader = ' '`はリーダーキーをスペースに設定し、`vim.opt.tabstop = 2`はタブ幅を2に設定します。

  • Neovimでモジュール化された設定はどのように実現しますか?

    -Luaの`require`関数を使用して、設定をモジュール化できます。各機能やプラグインの設定を別々のLuaファイルに分けて、`init.lua`から必要なモジュールを読み込むことで、設定を整理できます。

  • Packer.nvimはどのような役割を果たしますか?

    -Packer.nvimはNeovimのパッケージ管理システムで、Luaで記述されたプラグインや機能を管理するためのツールです。非同期インストール、ポストインストールおよびアップデートフック、表現力のある設定、遅延ローディングオプションなど、多くの便利な機能を提供しています。

  • Packer.nvimをインストールするにはどうすればいいですか?

    -Packer.nvimをインストールするには、まず`init.lua`ファイル内で`require('packer').sync()`を呼び出します。その後、Packerのブートストラップ関数を使用して、Packer自体をインストールします。

  • Neovimでカラースキームを変更するにはどうすればいいですか?

    -Neovimでカラースキームを変更するには、例えば`groovebox`というカラースキームをインストールし、`init.lua`ファイル内で`vim.cmd('colorscheme groovebox')`を呼び出すことで、カラースキームを設定できます。

  • Nvim-treeとEnvy-web-dev-iconsは何ですか?

    -Nvim-treeはファイルシステムのブラウザのようなツールで、Envy-web-dev-iconsはファイルやディレクトリにアイコンを表示するプラグインです。これらを使用することで、Neovimのファイルブラウジングと可視性が向上します。

  • Lualineは何ですか?

    -LualineはNeovimのステータスラインをカスタマイズするためのプラグインで、Powerlineのような見た目を提供します。Luaで書かれており、カスタマイズ性が高いです。

  • Tree-sitterとTelescopeは何ですか?

    -Tree-sitterは構文ハイライトのためのライブラリで、TelescopeはNeovimで様々な検索やフィルタリングを行うためのプラグインです。これらを使用することで、コードの可読性や検索機能を向上させることができます。

  • プラグインの設定をどのように整理するのですか?

    -プラグインの設定は、それぞれのプラグインごとにLuaファイルを作成し、`~/.config/nvim/lua/`ディレクトリ内に配置することで整理できます。これにより、設定がモジュール化され、管理しやすくなります。

Outlines

00:00

📘 NeovimのLuaコンフィグレーション入門

この段落では、Neovimの設定と理解の方法について説明されています。特にNeovimには様々なアイデアと慣習があり、混乱を避けることは難しいとされています。このビデオでは、Luaで書かれた非常にシンプルで理解しやすい設定から始め、Neovimを美しく見せることができます。この設定には、nerdtreeの構文高亮、tree-setter、telescopeの曖昧さ検索とファイル検索、luolineなどが含まれています。

05:00

📘 Luaを使ったNeovimの設定

この段落では、Luaを使ったNeovimの設定方法が紹介されています。Luaは軽量で組み込みやすいプログラミング言語で、関数型、手続き型、オブジェクト指向型のプログラミングを標準でサポートしています。NeovimのLuaは、設定のための便利な機能とバインディングも提供しています。新しいVim設定から始め、init.luaファイルを作成し、いくつかのVim設定をLuaコードで行います。また、Luaがモジュールを読み込むことができるので、設定をモジュール化することができます。

Mindmap

Keywords

💡Neovim

Neovimは、Vimの拡張版で、より高度な機能とスクリプト言語Luaのサポートを備えたテキストエディタです。このビデオでは、Luaを使用してNeovimをカスタマイズする方法について説明されています。

💡Lua

Luaは、軽量で組み込み可能なプログラミング言語で、関数型、手続き型、オブジェクト指向型のプログラミングをサポートしています。Neovimでは、Luaを使用してエディタをカスタマイズすることができます。

💡Configuration

Configuration(設定)は、ソフトウェアやシステムの動作を調整するために使用されるパラメータやオプションの集まりです。このビデオでは、Neovimの設定をLuaでカスタマイズする方法が紹介されています。

💡Nerdtree

Nerdtreeは、Neovimのプラグインで、ファイルシステムのエクスプローラーを提供します。これにより、ファイルやディレクトリを効率的にナビゲートできます。

💡Telescope

Telescopeは、Neovimのプラグインで、様々な検索やフィルタ機能を提供します。これにより、ファイル内やプロジェクト全体での検索が簡単になります。

💡Luoline

Luolineは、Neovimのプラグインで、ステータスラインをカスタマイズするためのツールです。これにより、エディタのステータスバーをより視覚的に魅力的なものにすることができます。

💡Packer.nvim

Packer.nvimは、Neovimのパッケージ管理システムで、プラグインのインストール、更新、管理を簡単に行うことができます。

💡Modularization

Modularization(モジュール化)は、ソフトウェアやシステムを個別の機能単位に分割し、それらを独立して作成・管理することを指します。このビデオでは、Neovimの設定をモジュール化することで、より効率的で理解しやすい設定ファイルを作成する方法が説明されています。

💡Keymaps

Keymaps(キーマップ)は、特定のキーストロークを特定のアクションに割り当てる設定です。このビデオでは、NeovimのキーマップをLuaで定義する方法が紹介されています。

💡Color Scheme

Color Scheme(カラースキーム)は、エディタやターミナルの背景色、文字色、ハイライト色などを統一的に設定するテーマです。このビデオでは、Grooveboxというカラースキームを使用してNeovimの外観をカスタマイズする方法が紹介されています。

💡Web Dev Icons

Web Dev Iconsは、Nerdtreeで使用されるプラグインで、ファイルやディレクトリにアイコンを表示します。これにより、ファイルの種類を視覚的に理解しやすくなります。

Highlights

Introducing a minimal and easy to understand Neovim configuration in Lua, covering essential plugins like NERDTree, Tree-sitter, Telescope, and LuaLine.

The struggle with VimScript and the transition to Lua for a more understandable Neovim configuration.

Lua's lightweight and versatile programming capabilities enhancing Neovim configuration.

Starting Neovim configuration from scratch with init.lua, showcasing basic Lua code for Vim settings.

Modularizing the Neovim configuration for better organization and easier management.

Introduction and setup of Packer.nvim as the package manager for extending Neovim's functionality.

Configuring Neovim with essential plugins like Groovebox for color scheme, nvim-tree, and nvim-web-dev-icons.

Setting up LuaLine for a powerful status line in Neovim.

Organizing plugin configurations into separate files for a clean and modular setup.

Adding and configuring Tree-sitter for advanced syntax highlighting.

Integrating Telescope for enhanced file searching and fuzzy finding.

Highlighting the power of Neovim's Lua configuration through a comprehensive setup walkthrough.

The complete Neovim setup showcases a beautiful, efficient, and minimal configuration.

Teasing future content on configuring Language Server Protocol (LSP) with Neovim for an in-depth development environment setup.

Encouragement to subscribe for upcoming tutorials on enhancing the Neovim development environment.

Transcripts

play00:00

foreign if you're looking to configure

play00:03

and more importantly understand your Vim

play00:05

configuration it can be a daunting task

play00:08

with neovim specifically there are a lot

play00:10

of competing ideas and conventions

play00:12

making it easy to get lost in the weeds

play00:14

in this video I'm going to show you how

play00:16

to make neovim look beautiful with a

play00:19

very minimal and easy to understand

play00:20

configuration written in Lua from

play00:23

scratch this covers nerdtree syntax

play00:25

highlighting with tree Setter telescope

play00:27

for fuzzy finding and file finding

play00:29

luoline and others please be sure to

play00:31

like And subscribe let's get into it

play00:37

now I have a confession to make

play00:39

vimscript never quite made sense to me

play00:42

so half the time I was reconfiguring my

play00:44

Vim configuration I didn't understand

play00:46

what the hell I was doing neovim has

play00:48

changed that it comes with a scripting

play00:50

language built in called Lua Lua is a

play00:53

lightweight embeddable programming

play00:55

language that supports functional

play00:56

procedural and object-oriented

play00:58

programming out of the box the neovim

play01:01

instance of Lua also comes with a lot of

play01:03

helpful features and bindings for

play01:05

configuring them let's check this out

play01:07

with a new Vim configuration from

play01:09

scratch neovim supports loading in a

play01:11

knit.lua file for configuration instead

play01:13

of the usual init.vim so let's start

play01:16

there we will CD into our config nvim

play01:18

directory and create a new init.lua file

play01:22

now to start things off let's put in a

play01:24

couple of Vim settings that I'm

play01:26

comfortable with first of all you'll

play01:27

note that this is all actually Lua code

play01:30

this vim.g and vim.opt things are meta

play01:35

accessors which essentially call lower

play01:36

level luo functions that call the Vim

play01:39

API to set key bindings and options for

play01:42

them and in this small initial init.lua

play01:45

I set my leader to space I use tab stop

play01:48

shift width shift round just things that

play01:51

I like to use in my normal programming

play01:52

experience and I set one keymap to

play01:55

leader h to clear any search that I

play01:57

might have just done so now if we write

play01:59

and Source this file we can see that

play02:02

it's already working and if I search for

play02:04

something and type leader h it will

play02:06

clear the search great so this initial

play02:08

init.lua file is great and all but we're

play02:11

not really taking advantage of anything

play02:12

that Lua gives us Lua can load modules

play02:15

in the Lua path in nvim so what we can

play02:18

do is modularize our configuration and

play02:22

make it look something like this making

play02:24

our configuration more modular makes it

play02:26

easier to work with and easier to

play02:28

understand so let's get started with

play02:30

that we'll move our init.lua code into a

play02:33

new file under nvim Lua core

play02:37

keymaps.lua essentially this creates a

play02:41

new module under

play02:42

lua.core.keymaps so we paste all our

play02:45

code from before and we go back to our

play02:46

initial init.lua file and just make sure

play02:48

we require

play02:50

keymaps.lua in the

play02:52

lua.core.keymaps module

play02:55

if we source and load this file we see

play02:57

that nothing has changed which means

play02:58

everything still works

play03:01

next we want to install a package

play03:03

manager so we can add more functionality

play03:05

and Beauty to this neovim configuration

play03:07

I like to use packer.nvim it's a package

play03:10

management system or neovim that has a

play03:13

lot of interesting features like being

play03:15

written in Lua configured in Lua async

play03:17

installation post install and update

play03:19

hooks expressive configuration and lazy

play03:22

loading options Packer is really cool

play03:24

now in the docs Packer has a quick start

play03:27

section that teaches you how to download

play03:28

install Packer and then add it to your

play03:32

plugins.lua file but my favorite way to

play03:35

install Packer is with their

play03:36

bootstrapping helper functions now

play03:39

essentially how this works is we write a

play03:40

function that checks if Packers already

play03:42

installed and if not we want to install

play03:44

Packer and call sync which will install

play03:47

all of the packages that you have listed

play03:49

here let's copy and paste this into our

play03:51

config nvim Lua core

play03:55

plugins.luophile next we want to make

play03:57

sure we require our new plugins.lua file

play04:01

in our init.lua we want to quit neovim

play04:05

reopen it and we can see that Packer is

play04:07

working hard to install our plugins now

play04:09

it's working great now let's use Packer

play04:12

to install some plugins to make this

play04:14

neovim configuration beautiful we

play04:16

install groovebox as a color scheme it's

play04:19

just my favorite there are plenty of

play04:20

others out there we also install nvim

play04:22

tree and envium web dev icons the web

play04:26

dev icons displays really cool icons in

play04:28

the nvim tree so we like that next we

play04:31

install NVM luoline which is a really

play04:33

cool looking power line type thing for

play04:35

neovim now if we save this file and run

play04:38

Packer sync Packer will install all of

play04:41

the new packages that we just wrote

play04:42

pretty cool now we need to set up all

play04:45

these plugins we just installed and we

play04:47

do this by creating a new module called

play04:49

plug-in config under our Lua core

play04:52

namespace and we do this by creating a

play04:54

new folder called plug-in config within

play04:57

our Lua core directory inside of plug-in

play05:00

config directory we're going to create a

play05:02

new file for each plugin that we just

play05:04

installed this is great because it keeps

play05:07

everything modular and each plugins

play05:09

configuration has its own file so we're

play05:12

going to create three files groovebox

play05:14

nvim tree and luoline now we want to

play05:17

edit each of these files to add the

play05:19

configurations for each plugin in groov

play05:21

box we want to set our term groy colors

play05:24

to true and we want to add a Vim command

play05:26

to set our color scheme to groovebox in

play05:29

Lua line we want to paste a simple

play05:32

config that makes our theme groovebox

play05:34

which matches with our color theme and

play05:37

sets icons enabled to true we also have

play05:39

a little bit extra here because I like

play05:41

seeing the full path of my file in the

play05:44

first section of luoline which is under

play05:46

sections lure line a and then an nvim

play05:49

tree we want another simple

play05:50

configuration where we want to disable

play05:53

netrw and we want to require nvim tree

play05:56

and set it up with no options and we

play05:59

want to set a new keymap control n and

play06:01

now that will toggle nvim tree find file

play06:04

toggle and this is actually a really

play06:06

cool setup whenever you type control n

play06:08

Envy on tree will find the file you're

play06:10

currently in and open the directory in a

play06:13

new tree it's pretty neat next we want

play06:15

to create a new init.lua file in our

play06:18

plugin config directory this init.lua

play06:21

file will require all of our

play06:23

configurations and then in our base

play06:25

init.lua file we want to require our

play06:28

plugin configuration and this is doable

play06:31

because our init.lua in the plugin

play06:33

configuration directory makes it so that

play06:35

we can require this namespace wholesale

play06:37

now if we CD back into our base

play06:40

directory for our neovim if we open

play06:43

neovim we can see that all of our

play06:45

plugins are automatically sourced and

play06:47

everything looks amazing we have

play06:48

nerdtree on the left we can browse our

play06:51

files we can see that groovebox theme

play06:53

and we can see Lua line down there

play06:55

looking great nice now we want to add

play06:59

two new plugins to our configuration

play07:00

call called tree sitter and Telescope we

play07:04

can navigate to our plugins Lua file by

play07:08

going through nerd tree and we want to

play07:09

install tree sitter and Telescope tree

play07:12

centers for syntax highlighting and

play07:13

telescope is for a bunch of awesome

play07:15

things we can write and quit the file

play07:17

and we reload neovim and we dive into

play07:21

the directory and we call Packer sync

play07:23

and Packer sync will sync up all the

play07:25

files it'll download our new plugins and

play07:29

we can continue with configuration

play07:34

now we want to create two new

play07:35

configuration files one for tree sitter

play07:37

and one for telescope

play07:49

on telescope we want to paste the small

play07:51

config that gives us a couple little

play07:52

helper functions Ctrl P for built-in

play07:54

files and things like that

play07:58

in our trees that are config we want to

play08:00

paste in another little bit of

play08:02

configuration just to ensure we have a

play08:04

couple of our languages that we want to

play08:06

make sure we're highlighting in syntax

play08:07

now we want to drill back down to our

play08:09

net.lua in our plugin config directory

play08:12

and make sure we require those two new

play08:14

plugin configurations

play08:19

if we quit and reload Vim we can see

play08:21

that tree sitter is downloading these

play08:23

parsers for the languages that we

play08:25

specified now let's show everything off

play08:27

if we open nvim we can see that we have

play08:30

our fine files from telescope we see

play08:32

nvim tree sitters and highlighting all

play08:35

of our syntax we have nerd tree we have

play08:38

grapping of things within our files of

play08:40

strings and we have a bunch of cool

play08:43

stuff lualine looks amazing our color

play08:46

scheme looks amazing this whole entire

play08:48

setup looks amazing and this was done

play08:51

really really quickly with very minimal

play08:53

configuration

play08:54

pretty cool

play08:56

I hope you enjoyed this complete

play08:58

tutorial of how to build a neovim

play09:00

configuration in Lua from scratch we

play09:02

made an awesome modular configuration

play09:04

and everything looks really really cool

play09:07

one thing you might have noticed is that

play09:08

I did not go over LSPs and I didn't do

play09:11

that because that is going to be my next

play09:12

video so please subscribe and make sure

play09:15

you tune in for the next one on LSPs

play09:17

with Mason

play09:19

thanks

Rate This

5.0 / 5 (0 votes)

Ähnliche Tags
NeovimLua設定チュートリアルモジュール化Packer.nvimgruvboxNvimTreeTelescopeTreeSitterプログラミング
Benötigen Sie eine Zusammenfassung auf Englisch?