Giter Site home page Giter Site logo

iyue / insisvim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nshen/insisvim

0.0 0.0 0.0 12.48 MB

🗃 An out-of-the-box Neovim IDE solution that setup development environment in an incredibly simple way.

Home Page: https://insisvim.github.io

License: MIT License

Lua 100.00%

insisvim's Introduction

InsisVim

一个开箱即用的 Neovim IDE 层,以难以置信的简单方式配置开发环境,例如配置 golang,只需:

require("insis").setup({
  golang = {
    enable = true,
    lsp = "gopls",
    linter = "golangci-lint",
    formatter = "gofmt",
    format_on_save = true,
  },
})

:wq 保存重启后,会自动安装语法高亮和 Golang Language Server,Linter,Formatter 等。

🛠 安装

install.mp4

注意事项

  • 如缺少以下常见命令行工具,gitwgetcurlripgrepnvim v0.9.x,则有可能安装失败。

    • 在 Mac 上,您可以使用 brew install 安装以上工具。
    • 在 Ubuntu 上,您可以检查 Ubuntu 安装指南
  • 如之前安装过其他配置,建议先删除或备份以下目录

    • ~/.local/share/nvim
    • ~/.cache/nvim
    • ~/.config/nvim

安装步骤

  1. 克隆本项目到 Neovim 配置目录
git clone https://github.com/nshen/InsisVim.git ~/.config/nvim
  1. 运行 nvim ,等待插件全部安装完成

  2. 重启

自定义配置

自定义配置非常简单,就像配置一个插件一样,只需要修改 ~/.config/nvim/init.lua 后保存重启即可

require("insis").setup({
    -- 按需设置参数
})

这里支持的参数非常的多,但基本上分为常用配置,和编程环境配置

常用配置

例如用来设置主题的 colorscheme 这类常用的配置,修改后 :wq 保存重启即可生效

require("insis").setup({
    colorscheme = "tokyonight"
})

InsisVim 默认使用 tokyonight 主题,同时内置了 nordonedarkgruvboxnightfoxnordfoxduskfoxdracula 主题。 可以通过 :InsisColorPreview 命令预览内置主题

colorscheme.mp4
Copilot 配置
require("insis").setup({
  cmp = {
    -- 启用 copilot
    copilot = true,
  },
})

InsisVim 内置了以下插件,启用后会使其生效

因为 copilot 是收费的,首次使用需要运行 :Copilot auth 认证后才会生效,但如果你是学生老师或者开源项目贡献者,可以申请免费使用。

GitHub Copilot is free to use for verified students, teachers, and maintainers of popular open source projects.

Buffers

在 Vim 世界里,Buffer 表示已经加载到内存中的文件。非常像 VSCode 中的 Tab 页,在 VSCode 里看到一个标签页,就表示一个文件加载到内存中了。

在 InsisVim 中使用 bufferline.nvim 插件来模拟这种行为,并且简化了配置,非常容易定制按键

bufferline.mp4
Bufferline 配置
require("insis").setup({
  bufferLine = {
    enable = true,
    keys = {
      -- left / right cycle
      prev = "<C-h>",
      next = "<C-l>",
      -- close current buffer
      close = "<C-w>",
      -- close = "<leader>bc",
      -- close all left / right tabs
      close_left = "<leader>bh",
      close_right = "<leader>bl",
      -- close all other tabs
      close_others = "<leader>bo",
      close_pick = "<leader>bp",
    },
  },
})

Super Windows

和 VSCode 不同,Vim 中的 Window 只是显示 Buffer 的窗口,允许多个窗口同时显示甚至修改一个 Buffer,在 InsisVim 中可以非常简单的定义一系列窗口相关的快捷键,包括水平垂直分割,快速窗口之间跳转,关闭等,称为 Super windows。

Super Windows 配置
require("insis").setup({
  s_windows = {
    enable = true,
    keys = {
      split_vertically = "sv",
      split_horizontally = "sh",
      -- close current
      close = "sc",
      -- close others
      close_others = "so",
      -- jump between windows
      jump_left = { "<A-h>", "<leader>h" },
      jump_right = { "<A-l>", "<leader>l" },
      jump_up = { "<A-k>", "<leader>k" },
      jump_down = { "<A-j>", "<leader>j" },
      -- control windows size
      width_decrease = "s,",
      width_increase = "s.",
      height_decrease = "sj",
      height_increase = "sk",
      size_equal = "s=",
    },
  },
})

Super Tab

Vim 中的 Tab 是用来保存一个或多个 windows 组合,这样你就可以在不改变 windows 布局的情况下,切换到不同的 Tab, 用不同的 windows 布局来做不同的事。

在 InsisVim 中也可以快速的定义一组 tabs 相关的快捷键,称为 Super Tab

Super Tab 配置

注意 super tab 并不常用,所以默认是关闭的,需要手动启用

require("insis").setup({
  s_tab = {
    enable = false, -- 默认关闭
    keys = {
      split = "ts",
      prev = "th",
      next = "tl",
      first = "tj",
      last = "tk",
      close = "tc",
    },
  },
})

简单讲 Buffers & Windows & Tabs 三者的关系如下:

  • buffer 是加载到内存的文件,我们用 bufferline 插件模拟类似 VSCode 的 Tab页 行为
  • window 负责显示buffer,熟悉快速分割窗口,在不同窗口快速跳转的快捷键是提高开发效率的关键
  • tab 负责组织 windows 布局,通常用不到,所以默认是关闭的
image

编程环境配置

例如 Golang 环境,设置 enable 后,:wq 保存重启会自动调用 Mason 安装对应的语法高亮 Language Server,Linter,Formatter 等。安装完毕后再次重启打开对应的 Golang 项目即可生效

require("insis").setup({
  colorscheme = "tokyonight"
  golang = {
    enable = true,
  },
})

开启其他语言相关的模块也都类似,修改 ~/.config/nvim/init.lua 后保存重启,即可自动完成安装。

由于编程环境启用后需要额外安装LSP Linter Formatter 语法高亮等,所以默认情况下编程环境配置都是关闭的,需要手动开启,只有 Lua 是默认开启的,这是因为你会经常使用 Lua 语言来修改配置。而 常用配置 则大部分默认都是开启状态的。

完整默认参数列表在此 config.lua

常用编程环境配置

语言环境相关模块请逐个打开,否则重启后一次会安装很多服务,需要等待较长时间。

Markdown 编辑
require("insis").setup({
  markdown = {
    enable = true,
    -- 以下为默认值,可以省略
    mkdnflow = {
      next_link = "gn",
      prev_link = "gp",
      next_heading = "gj",
      prev_heading = "gk",
      -- 进入链接
      follow_link = "gd",
      -- 从链接返回
      go_back = "<C-o>",
      toggle_item = "tt",
    },
    formatter = "prettier",
    -- 保存时格式化默认为false
    format_on_save = false,
  },
})

启用 markdown 功能后,重启会自动安装 Treesitter 的 markdown 语法高亮,和 prettier 用于格式化。

增加 :MarkdownPreview 命令实时预览 markdown 文件

增加 mkdnflow.nvim 相关的快捷键

增加 markdown 相关快捷键例如 5x5table

前端开发

前端开发配置相对比较复杂,因为需要安装多个 LSP,多种文件的语法高亮等,重启后需要等待时间会较长

require("insis").setup({
  frontend = {
    enable = true,
    -- 下边的都是默认值可以省略
    linter = "eslint_d",
    ---@type "eslint_d" | "prettier" | "tsserver"
    formatter = "tsserver",
    format_on_save = false,
    cspell = false,
    tailwindcss = true,
    prisma = false,
    -- vue will take over typescript lsp
    vue = false,
    -- extra lsp command provided by typescript.nvim
    typescript = {
      keys = {
        ts_organize = "gs",
        ts_rename_file = "gR",
        ts_add_missing_import = "ga",
        ts_remove_unused = "gu",
        ts_fix_all = "gf",
        ts_goto_source = "gD",
      },
    },
  },
})
Golang开发
require("insis").setup({
  golang = {
    enable = true,
    -- 下边的都是默认值可以省略
    lsp = "gopls",
    linter = "golangci-lint",
    formatter = "gofmt",
    format_on_save = false,
  },
})
clangd开发
require("insis").setup({
  clangd = {
    enable = false,
    lsp = "clangd",
    -- linter = "clangd-tidy",
    formatter = "clang-format",
    format_on_save = false,
  },
})
Bash开发
require("insis").setup({
  bash = {
    enable = true,
    lsp = "bashls",
    --  brew install shfmt
    formatter = "shfmt",
    format_on_save = false,
  },
})
Python开发
require("insis").setup({
  python = {
    enable = true,
    -- can be pylsp or pyright
    lsp = "pylsp",
    -- pip install black
    -- asdf reshim python
    formatter = "black",
    format_on_save = false,
  },
})
Ruby开发
require("insis").setup({
  ruby = {
    enable = true,
    lsp = "ruby_ls",
    -- gem install rubocop
    formatter = "rubocop",
    format_on_save = false,
  },
})

TODO...

日常使用

TODO

快捷键列表

项目结构

如何扩展

TODO

Requirements

  • Neovim v0.9.x.
  • Nerd Fonts.

License

MIT

WIP 🟡, PR is welcome.

insisvim's People

Contributors

nshen avatar lizhuoran1019 avatar s-leeq avatar charles1614 avatar pad0van avatar diaozxin007 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.