Skip to content

Repository files navigation

Neovim Configuration

图片

Introduction zh_CN

I used to use LazyVim. It's awesome. But I found it kind of hard to keep tweaking Neovim on top of LazyVim. It's more convenient to manage if I have a LazyVim in stdpath('config') instead of stdpath('data'). And most importantly — It's really cool to have my own Neovim configuration, isn't it?

Requirements

Installation

Honestly, I wouldn't recommend using my configuration directly. It's quite personal. Some CLI tools integrated might be useless to you. Also, I'm not using DAP or NeoTest currently. Still, I think it will serve as a good reference or starting point for you to build your own configuration alongside LazyVim (which is also my reference). I'll even brag a bit that I have injected some ingenuity inside my configuration — Let me show you below:

git clone https://github.com/Lingshinx/nvim-config.git ~/.config/nvim

Tip

If you already have a Neovim setup in your environment, You don't need to move the current one away as a backup. You can clone this repo to $XDG_CONFIG_COME/{NVIM_APPNAME}. Any appname as NVIM_APPNAME is okay as long as it won't conflict with your existing directories. For example, you can choose nvim_lingshin as NVIM_APPNAME for my configuration.

git clone https://github.com/Lingshinx/nvim-config.git ~/.config/nvim_lingshin

then, try mine by running:

NVIM_APPNAME=nvim_lingshin nvim

Features

Plugin Manager

Plugin configurations are in ~/.config/nvim/lua/plugins, just same with lazy.nvim.

The Plugin Spec is quite like lz.n (sure, it will be registered in lz.n after all).

Property Type Description
[1] string? The plugin's repo, It's the equivalent to the [1] of lazy.nvim
name string? The plugin's name (not the module name). This is what is passed to the load(name) function.
url string? The plugins's url, param for vim.pack.add, for example https://codeberg.org/abcd/efg
main string? The main module used for setup()
version string? or vim.VersionRange Version to use for install and updates.
dir string? local plugin, It's pity that git repo is still needed
enabled boolean? or fun():boolean When false, or if the function returns false, then this plugin will not be included in the spec.
beforeAll fun(lz.n.Plugin)? Always executed before any plugins are loaded.
before fun(lz.n.Plugin)? Executed before a plugin is loaded.
after fun(lz.n.Plugin)? Executed after a plugin is loaded.
event string? or string[] Lazy-load on event. Events can be specified as BufEnter or with a pattern like BufEnter *.lua.
cmd string? or string[] Lazy-load on command.
ft string? or string[] Lazy-load on filetype.
keys string? or string[] or lz.n.KeysSpec[] Lazy-load on key mapping.
colorscheme string? or string[] Lazy-load on colorscheme.
lazy boolean? Lazy-load manually, e.g. using trigger_load. Will disable lazy-loading if explicitly set to false.
priority number? Only useful for start plugins (not lazy-loaded) to force loading certain plugins first. Default priority is 50.
opts? table same with lazy.nvim
load_before string or string[] mark a plugin as a dependencies of others

Language

It's convenient to treat Language configurations as packages and manage them together instead of scattering them around.

You can put language configurations at {rtp}/lua/langs or just ~/.config/nvim/langs.

Property Type Description
[integer] string or Config.LangConfig you can nest multiple languages inside a language. Parent configurations are inherited, I will show you the usage below
treesitter string[] or boolean default to true, treesitter-{language name} will be installed
lsp string, string[] or table<string,lspconfig> name of Language Server Protocol, when table, vim.lsp.config(key, value) will be called
formatter string or string[] name of formatters
plugin utils.pack.Spec plugin configurations related to this language
option table<string,any> language-specific options
filetype table<string,string|table> register new filetypes
parser string or ParserInfo url to download custom treesitter parser, see also: Adding custom languages
package string[] if the package name in installer is different with name of LSP and formatter, you can set package to specify
nix string[] or string nixpkg name, needed when the name is only valid in nix
mason string[] or string name in mason, needed when the name is only valid in mason

Example about how to configure languages.

Also, my own language configurations are placed in template/langs/, You can copy some of them to stdpath('config')/langs to enable.

Feel free to PR your own language configuration to me if you like this functionality. Since those configuration aren't applied automatically, so I'd really appreciate your contribution whatever the language is.

FileType Picker

Use <leader>sf to search filetypes.

record.mp4

Thanks to the feature above that I can display informations of formatter, Tree-sitter, and LSP for each language.

Use <Shift-Enter> to edit language configuration.

Root and Cwd

I prefer not to make difference between cwd and root. When you enter to a buffer attached to a file, My Neovim will change current directory to the root of that file. When root directory cannot be detected, default to parent directory.

Oil, Tabline and Harpoon

图片

I agree with the opinion that you should not turn your Neovim into a traditional IDE.

Use tabline instead of bufferline.

Stack your buffers to overflowing and navigate with H / L? A true Vim ninja wouldn't do that.

Here's lots of ways to open new windows in a new tab, Tab on Oil, Grapple, Overseer and Ctrl-Enter on Snacks picker.
fatten.nvim also open a new Tab for files open in terminal builtin.

By the way, You can <Ctrl-w>T to move current window to a new tab.

Note

Statusline and Tabline are all powered by heirline

Reference

Why do Vim experts prefer buffers over tabs? - Stack Overflow

Don't rely on File Tree Explorer, Instead, use File Fuzzy Picker and Harpoon to jump around files.

Actually, I still use snacks.explorer. It's not bad to have a file tree for a quick overview of the project's structure.

Oil.nvim is awesome, powerful and vim-like. You should try.

Oil.nvim is even more effective at filesystem editing than yazi in my practice.

Kitty Scrollback

I use Neovim as kitty scrollback pager.

record.mp4

Inspired by kitty-scrollback.nvim

It just colorize the buffer and set some keymaps and options, more lightweight.

To enable, please add this options in kitty configuration.

scrollback_pager nvim -c 'set filetype=scrollback'

Workspace Config

Use the ./.nvim directory to store local configurations. Refer to Workspace for more details.

Overseer

Vim has a special mode to speedup the edit-compile-edit cycle.

I would like to use :make to compiler or run my codes. But :make is synchronous. So I do nothing but checking my phone while compiling my codes.

Overseer is a powerful plugin to manage tasks.

  • Convenient to launch a task from files like Makefile, JustFile, package.json, tasks.json, etc.
  • Easy to restart a process.
  • Dynamically tweak functionality by editing components.
  • Notify when task finish or failed.
  • Even able to watch file changes and then restart automatically.
  • Interoperable with vim.quickfix and vim.diagnostic.

Usage

:Make to run programs determined by vim.o.makeprg. Parse the error message with vim.o.errorformat and display it with trouble.nvim.

:Grep to search keyworks with quickfix interactively. I use ripgrep as vim.o.grepprg. So no need to worry about performance.

<leader>oo to restart lastest tasks 1.

<leader>os to run a shell command.

record.mp4

LaTeX Suite

latex.mp4

Obsidian-like LaTeX Suite powered by LuaSnip.

Note

Only available in Markdown math blocks, since I'm not using LaTeX.
<leader>ut to toggle Auto Snippets Trigger.

Warning

not available now, I'm fixing, sorry

Dashboard Header

I manually painted a few Logo with unicode for me and friends of mine.

图片

You can also be friend of mine. And feel free to open an issue if interested in my nvim-config. I'll draw a custom Logo for you when I have time.

I'm unable to make so many friends. So, hurry up?

Okay, take it easy, I think there is no chance that I will be followed by 100+ friends.

Footnotes

  1. Choose a task generated by task templates when no lastest available. ↩

About

nvim config. Quite like LazyVim. but easier to config, and well organized, maybe? I considered

Topics

Resources

Stars

19 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages