安装

我是在ubuntu安装这里就以linux为例,其他操作系统参考官方英文文档(注意是英文文档,中文文档更新比较慢)

1
git clone https://github.com/NvChad/starter ~/.config/nvim && nvim

注意:插件的安装都是从GitHub上面拉取的,建议使用科学上网

卸载方法

1
2
3
4
5
6
7
8
9
# Linux / Macos (unix) 
rm -rf ~/.config/nvim
rm -rf ~/.local/share/nvim
# Windows CMD
rd -r ~\AppData\Local\nvim
rd -r ~\AppData\Local\nvim-data
# Window PowerShell
rm -Force ~\AppData\Local\nvim
rm -Force ~\AppData\Local\nvim-data

配置

新版本的配置文件夹里面没有了custom文件夹

lsp代码提示配置

  1. 首先进入neovim之后输入:Mason安装好你需要的lsp server
  2. 进入configs文件夹,手动创建lspconfig.lua文件,并复制以下内容进去
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    local configs = require("nvchad.configs.lspconfig")

    local on_attach = configs.on_attach
    local on_init = configs.on_init
    local capabilities = configs.capabilities

    local lspconfig = require "lspconfig"
    local servers = { "html", "cssls", "clangd"} --这里输入你需要开启的服务,比如你要开启python-lsp-server,就在后面追加一个pylsp

    for _, lsp in ipairs(servers) do
    lspconfig[lsp].setup {
    on_init = on_init,
    on_attach = on_attach,
    capabilities = capabilities,
    }
    end

    -- Without the loop, you would have to manually set up each LSP
    --
    -- lspconfig.html.setup {
    -- on_attach = on_attach,
    -- capabilities = capabilities,
    -- }
    --
    -- lspconfig.cssls.setup {
    -- on_attach = on_attach,
    -- capabilities = capabilities,
    -- }

  3. 进入plugins文件夹在init.lua文件中追加以下内容
    1
    2
    3
    4
    5
    6
    7
    {
    "neovim/nvim-lspconfig",
    config = function ()
    require("nvchad.configs.lspconfig").defaults()
    require "configs.lspconfig"
    end
    },
    至此,lsp配置完毕,已经愉快的使用代码提示了

配置Jaq代码执行和平滑滚动

  1. 进入plugins文件夹创建pluginList.lua文件(这个文件名可以是任意文件名),填入以下内容,这里我采用了opts与plugin配置文件分开的写法
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    local overrides = require("configs.overrides")

    local plugins = {
    {
    "is0n/jaq-nvim",
    opts = overrides.jaqnvim,
    lazy = false
    },
    {
    "karb94/neoscroll.nvim",
    config = function ()
    require('neoscroll').setup {}
    end,
    lazy = false
    },
    }

    return plugins
    注意:这里lazy = false是必须的,不然这两个插件不起作用
  2. 进入configs文件夹,创建overrides.lua文件,填入以下内容(这里主要是Jaq的配置,可以参考Jaq官方github也可以直接copy我的配置)
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    local M = {}

    M.jaqnvim = {
    cmds = {
    -- Uses vim commands
    internal = {
    lua = "lusfile %",
    vim = "source %"
    },

    --Uses shell commands
    external = {
    markdown = "glow %",
    python = "python %",
    sh = "sh %",
    cpp = "cd $dir && g++ % -o $fileBase.exe && $dir/$fileBase.exe && rm $fileBase.exe",
    c = "cd $dir && gcc % -o $fileBase.exe && $dir/$fileBase.exe && rm $fileBase.exe"
    }
    },

    bahavior = {
    --Default type
    default = "terminal",

    --Start in insert mode
    startinsert = false,

    --Use "wincmd p" on startup
    wincmd = false,

    --Auto-save files
    autosave = false
    },

    ui = {
    float = {
    border = "none",
    winhl = "Normal",
    borderhl = "FloatBorder",
    winblend = 0,
    height = 0.8,
    width = 0.8,
    x = 0.5,
    y = 0.5
    },

    terminal = {
    position = "bot",
    size = 10,
    line_no = false
    },

    quickfix = {
    position = "bot",
    size = 10
    }
    }
    }

    return M

配置lr终端快捷执行当前代码文件

python为例:
进入到nvchad的配置文件目录,我的是/home/jym/.config/nvim/lua,编辑mappings.lua文件,新增如下代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
map('n', '<leader>lr',
function ()
require('nvchad.term').runner{
id = "boo",
pos = "sp",

cmd = function ()
local file = vim.fn.expand "%"
local ft_cmds = {
python = "python " .. file,
}

return ft_cmds[vim.bo.ft]
end,
}
end, {desc = "Run Current File"}
)

至此,Jaq,平滑滚动和快捷终端代码执行当前文件都配置完毕,重新进入neovim即可看到效果