# [配置] neovim
###### tags: `#learn`
> ## [[gituhb] 配置代碼](https://github.com/eggtoopain/Neovim-Configuration-Tutorial)
> [A Step-by-Step Guide to Configuring LSP in Neovim for Coding in Next.js (React), TypeScript, and TailWindCSS](https://levelup.gitconnected.com/a-step-by-step-guide-to-configuring-lsp-in-neovim-for-coding-in-next-js-a052f500da2)
### [創建] nvim配置檔
1. [創建] mkdir -p ~/.config/nvim
2. [創建] touch init.lua
3. [創建] 以下檔案結構

### [選項] options.lua
``` Lua
-- 變量
local opt=vim.opt
-- 行號
opt.relativenumber=true
opt.number=true
-- 縮進
opt.tabstop=4
opt.shiftwidth=4
opt.expandtab=true
opt.autoindent=true
-- 防止包裹
opt.wrap=false
-- 光標行
opt.cursorline=true
-- 啟用鼠標
opt.mouse:append("a")
-- 系統剪貼版
opt.clipboard:append("unnamedplus")
-- 默認新窗口右和下
opt.splitright=true
opt.splitbelow=true
-- 搜索不分大小寫
opt.ignorecase=true
opt.smartcase=true
-- 外觀
opt.termguicolors=true
opt.signcolumn="yes"
```
### [改鍵] keymaps.lua
``` Lua
-- 主鍵改為空格
vim.g.mapleader=" "
-- ---------- 視覺模式 ----------
-- 單行或多行移動
keymap.set("v", "j", ":m '>+1<CR>gv=gv")
keymap.set("v", "k", ":m '<-2<CR>gv=gv")
-- ---------- 正常模式 ----------
-- 取消高亮
keymap.set("n", "<leader>nh", ":nohl<CR>")
```
## [引入配置] init.lua
``` Lua
-- 引入 options.lua
require("core.options")
require("core.keymaps")
```
## [Error]
- [change mason-registry](https://github.com/williamboman/mason.nvim/discussions/1113)
``` lua
registries = {
"lua:mason-registry.index",
"github:mason-org/mason-registry@2023-03-27-cruel-jason",
},
```
nvim :MasonUpdate Failed to update registries: .../pack/packer/start/mason.nvim/lua/mason-core/log.lua:141: bad argument #2 to 'format' (string expected, got table)