/modern-neovim-configuration

Modern configuration for neovim.

Primary LanguageLuaMIT LicenseMIT

Modern Neovim Configuration

Neovim + Linux = Best Almighty IDE

This configuration is for linux only.

Mainly Supported Language/Framework List

  • Rust
  • Javascript/Typescript
  • Shell
  • SQL
  • Lua
  • GLSL
  • WGSL
  • Vue
  • React

To support a new one, check these.

  • treesitter
  • lsp
  • dap
  • formatter
  • source
  • snippet

Personal Environment

OS: Gentoo

Terminal: Alacritty

Neovim: V0.10+

Dependencies

  1. nodejs, go, rust (required for mason.nvim and nvim-treesitter). Use :h mason-requirements to check more dependencies.
  2. rg, fd command (required for telescope.nvim)
  3. trashy command (required for nvim-tree.lua)
  4. fcitx5 (required for fcitx.nvim)
  5. deeplx (required for translate.nvim)
  6. cargo-nextest (required for neotest-rust.nvim)
  7. @vue/typescript-plugin (required for vue project)
  8. dolphin (required for nvim-tree.lua)

QuickStart

Installation

  1. Install all dependencies.

  2. git clone https://github.com/niuiic/modern-neovim-configuration ~/.config/nvim

  3. Open neovim and then all plugins would be installed automatically.

  4. Install lsps, formatters, linters, debuggers with mason.nvim. Check lua/plugin/mason.lua for details.

  5. Check if something is missing with :checkhealth.

  6. Look for specific functions in lua/plugins.lua.

Keymap

which-key.nvim will tell you. Check lua/plugin/* and lua/keymap.lua for details.

leader: \

localLeader: <space>

LSP

Create lspname.lua in lua/lsp.

Update lsp_list in lua/lsp/init.lua.

Remap lsp commands with lsp-utils.nvim in lua/plugin/lsp-utils.lua.

Formatter

Use your favorite formatters with niuiic/format.nvim.

DAP

Create dapname.lua in lua/debugger.

Update debugger_list in lua/debugger/init.lua.

Custom Snippets and Sources

Create filetype.lua in lua/snippet or lua/source.

Update lang_list in lua/snippet/init.lua or lua/source/init.lua.

Snippet examples and snippet document may help you.

Config for Workspace

The root path of a workspace is where .git located. $rootPath/.nvim/init.lua is the entry of the local configuration.

Tasks

overseer.nvim is the default task manager. Here is the recommended way to define tasks.

  1. Create .nvim/task/ in the root path of the project.
  2. Add tasks to .nvim/task/task.sh and .nvim/task/init.lua.

.nvim/task/init.lua

local core = require("core")

local overseer = require("overseer")

local scriptPath = core.file.root_path() .. "/.nvim/task/task.sh"

overseer.register_template({
	name = "checkTs",
	builder = function()
		return {
			cmd = { scriptPath },
			args = { "checkTs" },
			components = { "on_output_quickfix", "default", "on_complete_notify" },
		}
	end,
})

overseer.register_template({
	name = "lint",
	builder = function()
		return {
			cmd = { scriptPath },
			args = { "lint" },
			components = {
				"on_output_quickfix",
				"default",
				"on_complete_notify",
			},
		}
	end,
})

.nvim/task/task.sh

set -eE

if [ "$1" = "checkTs" ]; then
	pnpm vue-tsc --noEmit
elif [ "$1" = "lint" ]; then
	pnpm lint:eslint --rule "no-console: error" -f unix
	pnpm lint:stylelint -f unix
fi
  1. chmod +x .nvim/task/task.sh
  2. Import .nvim/task/init.lua in .nvim/init.lua.

.nvim/init.lua

require("task")

These tasks must be able to be terminated automatically.

Showcase

Some functions are not convenient to display with pictures, please check lua/plugins.lua.

Status Line
Buffer Line
Diagnostic
Fuzzy Finder Search files, tags, buffers, history files, marks, projects, git status, etc.
AutoComplete CMD
Rename
Go to Reference
Keymap Suggestion
Code AutoComplete
Inner Terminal
Todo Comments
File Tree
Undo Tree
Translate
Unit Test
Tasks
Indentation Guides
Code Action
Colorful Brackets
Debug
Git Diff
Git Signs
Document
Quick Motion
Lsp Progress
Fold
Colorizer
Color Picker
Session
Quickfix
Startup Time
Lazygit
Jump to Marks
Pick Window
Divider