How to get the Vim you deserve
VIM
Let start from scratch…
Vim is a powerfull editor, I love its “minimal” look. You can connect on any server using ssh and have a perfectly working IDE. This alone makes me love Vim. Now add vim motions and some colors and I am in my safe zone…
I say Vim even though we will be using Neovim here, taking advantage of the LUA syntax.
I started using vim without plugins, then I switched to a “distribution”, NVChad which is packed with a bunch of very neat plugins. Now I am using a custom configuration inspired by this serie of videos.
Even though very good, I want to move to more minimalistic and even more custom configuration.
Initial Setup
We will use vim, nvim, neovim indifferently in this article.
If you like to play around and try different configurations, I would suggest adding the following aliases in your .zshrc
alias vim=nvim
alias vv='NVIM_APPNAME=custom-nvim nvim'
For more information on switching configs, I would recommend this website.
sudo pacman -S neovim
Once nvim is installed, open an empty document type the following command to know where vim is looking for its configuration.
:echo stdpath('config')
Distribution
NVChad
In order for NVchad to install all the necessary plugins we first need to install NPM and GCC
sudo pacman -S npm gcc base-devel
https://nvchad.com/docs/quickstart/install/
git clone https://github.com/NvChad/starter ~/.config/nvim && nvim
For uninstall remove those folders
# Linux / MacOS (unix)
rm -rf ~/.config/nvim
rm -rf ~/.local/state/nvim
rm -rf ~/.local/share/nvim
Then install the required plugins
:mason
lua-language-server # confirm with i
# quit with q
Set relative line numbers
Deactivate completion for markdown files
Last line position
in ~/.config/nvim/lua/chadrc.lua
-- This file needs to have same structure as nvconfig.lua
-- https://github.com/NvChad/ui/blob/v2.5/lua/nvconfig.lua
-- Please read that file to know all available options :(
---@type ChadrcConfig
local M = {}
-- Set relative line numbers
vim.wo.relativenumber = true
-- Deactivate autocomplete for Markdown files
vim.api.nvim_create_autocmd("FileType", {
pattern = "markdown",
callback = function()
-- Si nvim-cmp est configuré, désactivez-le en définissant une condition
local cmp = require('cmp')
cmp.setup.buffer({ enabled = false })
end,
})
-- Autocommande pour revenir à la dernière position dans le fichier
vim.api.nvim_create_autocmd("BufReadPost", {
callback = function()
local last_pos = vim.fn.line("'\"")
if last_pos > 0 and last_pos <= vim.fn.line("$") then
vim.api.nvim_win_set_cursor(0, {last_pos, 0})
end
end,
})
M.base46 = {
theme = "onedark",
-- hl_override = {
-- Comment = { italic = true },
-- ["@comment"] = { italic = true },
-- },
}
return M
TMUX integration
https://github.com/christoomey/vim-tmux-navigator
Add the plugin to the plugin list in ~/.config/nvim/lua/plugins/init.lua
return {
{
"stevearc/conform.nvim",
-- event = 'BufWritePre', -- uncomment for format on save
opts = require "configs.conform",
},
-- These are some examples, uncomment them if you want to see them work!
{
"neovim/nvim-lspconfig",
config = function()
require "configs.lspconfig"
end,
},
{
"christoomey/vim-tmux-navigator",
lazy=false,
},
{
"ThePrimeagen/vim-be-good",
lazy=false,
},
-- {
-- "nvim-treesitter/nvim-treesitter",
-- opts = {
-- ensure_installed = {
-- "vim", "lua", "vimdoc",
-- "html", "css"
-- },
-- },
-- },
}
And map the keys in ~/.config/nvim/lua/mappings.lua
require "nvchad.mappings"
-- add yours here
local map = vim.keymap.set
map("n", ";", ":", { desc = "CMD enter command mode" })
map("i", "jk", "<ESC>")
-- map({ "n", "i", "v" }, "<C-s>", "<cmd> w <cr>")
-- mapping for vim-tmux-navigator
map("n", "<C-h>", "<cmd>TmuxNavigateLeft<CR>")
map("n", "<C-l>", "<cmd>TmuxNavigateRight<CR>")
map("n", "<C-j>", "<cmd>TmuxNavigateDown<CR>")
map("n", "<C-k>", "<cmd>TmuxNavigateUp<CR>")
Custom NEOVIM
Switch between configs
Custom config
https://vincent.jousse.org/blog/fr/tech/configurer-neovim-comme-ide-a-partir-de-zero-tutoriel-guide/