Giter Site home page Giter Site logo

nvim's Introduction

NeoVim Configuration for Linux Kernel Development

This is a lua based, bootstrap-able NeoVim Configuration for C development (for example, Linux Kernel or Qemu).

1. Prerequisite

  1. Install NeoVim. Refer to NeoVim Installation Wiki
  2. Install ripgrep. Usually distributions already have it.
  3. Nerd Fonts are pretty icon fonts. It is better to install to have a good experience.
  4. Have access to github.com. Proxy may need to be configured if sitting in internal network.

2. Install

  1. Do following to cleanup previous nvim related configurations
rm -rf ~/.local/share/nvim
rm -rf ~/.local/state/nvim
rm -rf ~/.cache/nvim
  1. Clone this repo to ~/.config/nvim
  2. Launch 'nvim'. This will download all the necessary plugins automatically.
  3. Quit nvim, and relaunch nvim. That's it.

3. LSP and Language Servers

This configuration leverages LSP and Language servers to do auto-completion, go-to-definition, references, etc.

Refer to server_configurations.md on various language servers.

This configuration uses plugin mason to manage language servers. Use ':Mason' command to bring up mason interface.

Two language servers 'clangd' and 'lua_ls' are automatically installed. Use ':Mason' to bring up mason and install other language servers.

Sometimes language servers may fail to install. Usually that is because of environment issues, such as proxy is not configured properly.

3.1. Clangd and compile_commands.json

If it is C repo, the file compile_commands.json is needed for language server 'clangd' to work.

3.1.1. Linux Kernel

Run 'scripts/clang-tools/gen_compile_commands.py' after kernel compiling. This will generate compile_commands.json in the top directory.

After that, editing c file in the kernel repo will make clangd start to act as a language server.

3.1.2. Qemu

Qemu automatically generate a compile_commands.json in its build/ directory, so no extra actions is needed for Qemu.

4. Key Bindings

Mode Key Binding
n <SPACE>  Leader key
n tt Toggle Nvim-Tree on left side
n ts Toggle Symbols Outline on right side
n fc Telescope switch colorscheme
n ff Telescope find file
n fb Telescope find and switch buffer
n fw Telescope find and switch workspace
n fh Telescope find all commits that touch selected lines
n fg Telescope lsp dynamic workspace symbols
n <C-]> LSP go to definition
n <C-\>r Telescope lsp find symbol references
n <C-\>s Telescope grep word under cursor
n <C-\>t Telescope live grep
n <C-\>w Check out commit to a tmp workspace from a fugitive file buffer
n <C-g> Refine search for live grep & lsp-dynamic-workspace symbols
n <C-e> Toggle diagnostic messages from LSP server for a line
n K LSP hover on current word
n <ESC> Cancel search highlight
n <TAB> Goto next harpoon buffer, if no, go to next buffer
n <C-Left> Window vertical resize +1
n <C-Right> Window vertical resize -1
n <C-Up> Window resize -1
n <C-Down> Window resize +1
n <SPACE>w Switch window
n <C-n> Start a terminal
t <ESC> Back to normal mode in terminal

nvim's People

Contributors

x56jason avatar

Stargazers

yushuhuang avatar potato avatar Moon avatar Zhihang Zhang avatar redbeard avatar Marius Skunčikas avatar Brett Holman avatar Vadim Vetrov avatar 飞 avatar xorr0r0 avatar  avatar Redhawk avatar  avatar

Watchers

 avatar

nvim's Issues

request more compatible with NvChad

Hi it's good config for kernel developer I think but in my idea it's will be better if more compatible with NvChad and Base64 themes
also i think it's better to use NvChad mappings and these configs for better handle in options:

-- 使用 utf8 编码
vim.g.encoding = "utf-8"
vim.o.fileencoding = "utf-8"
-- 禁止折行显示文本
vim.o.wrap = true
-- 光标移动的时候始终保持上下左右至少有 8 个空格的间隔
vim.o.scrolloff = 8
vim.o.sidescrolloff = 8
-- 相对行号 方便进行数字范围的操作
vim.o.number = true
vim.o.relativenumber = false
-- 高亮显示光标所在行
vim.wo.cursorline = true
-- 显示左侧图标指示列
vim.wo.signcolumn = "yes"
-- 右侧参考线
vim.wo.colorcolumn = "80"
-- 使用空格替代 tab
vim.bo.expandtab = false
-- NORMAL 模式下 >> << 和 INSERT 模式下 CTRL-T CTRL-D 的缩进长度
vim.o.shiftround = true
-- 1 个 tab 移动 8 个空格
vim.o.shiftwidth = 8
-- 1 个 tab 显示为 8 个空格
vim.o.tabstop = 8
vim.bo.tabstop = 8
-- INSERT 模式下 1 个 tab 代表 8 个空格
vim.bo.softtabstop = 8
-- 新行对齐当前行
vim.bo.autoindent = true
vim.bo.smartindent = true
-- 搜索大小写不敏感 而在包含大写的时候让搜索变成大小写敏感
vim.o.ignorecase = true
vim.o.smartcase = true
-- 搜索结果不高亮显示
vim.o.hlsearch = true
-- 输入的同时搜索
vim.g.incsearch = true
-- 命令行高设置为 2 行
vim.o.cmdheight = 1
-- 当文件被外部程序修改的时候 自动加载修改后的内容
vim.g.autoread = true
vim.bo.autoread = true
-- 光标在行首的时候,使用左右方向键可以跳转到上一行或下一行
vim.o.whichwrap = "<,>,[,]"
-- 允许隐藏被修改过的 buffer
vim.o.hidden = true
-- 开启鼠标支持 - 仅在normal 和 virtual mode下
vim.o.mouse = "nv"
-- 禁止创建备份文件
vim.o.backup = false
vim.o.writebackup = false
vim.o.swapfile = false
-- 缩短 swap file 的更新时间间隔
vim.o.updatetime = 300
-- 设置快捷键触发的等待时间
vim.o.timeoutlen = 500
-- 分隔窗口的时候 新窗口从下面或者右边出现
vim.o.splitbelow = true
vim.o.splitright = true
-- 自动补全但是不会自动选中
vim.o.completeopt = "menu,menuone,noselect,noinsert"
-- 补全增强
vim.o.wildmenu = true
-- 补全最多 10 行
vim.o.pumheight = 10
-- 永远显示 tabline
vim.o.showtabline = 2
-- 使用增强状态栏插件后不需要 vim 的模式提示
vim.g.showmode = false
-- 样式
vim.o.background = "dark"
vim.o.termguicolors = true
vim.opt.termguicolors = true
-- 把空格显示成一个点
vim.o.list = false
vim.o.listchars = "space:·"

thank you

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.