start a new nvim config from scratch

This commit is contained in:
2025-11-14 22:49:45 -05:00
parent 158937509c
commit 2c2804273c
11 changed files with 219 additions and 0 deletions

37
CHEATSHEET.md Normal file
View File

@@ -0,0 +1,37 @@
# Neovim cheatsheet for this setup
## Save and exit
```vim
:w -- save file
w --
<leader>w --
:wq -- save and exit
<leader>wq --
:q -- exit without saving
<leader>q --
q --
:q! -- force to quit without saving
<leader>qq --
```
## Buffer navigation
```vim
:e <file> -- open a file in a new buffer
<leader>e --
:ls -- list buffers
<leader>ls --
:bnext -- goto next buffer
<leader>f --
:bprevious -- goto previous buffer
<leader>d --
```

19
README.md Normal file
View File

@@ -0,0 +1,19 @@
# Basic neovim configuration
To open [CHEATSHEET.md](./CHEATSHEET.md): `<leader>h`.
To open [README.md](./README.md): `<leader>hr`
## Used package
- [x] kanagawa: color schema
- [x] oil: files manager
- [x] mini-statusline
## References
- https://www.youtube.com/watch?v=g1gyYttzxcI

2
init.lua Normal file
View File

@@ -0,0 +1,2 @@
require("config.lazy")

8
lazy-lock.json Normal file
View File

@@ -0,0 +1,8 @@
{
"kanagawa.nvim": { "branch": "master", "commit": "aef7f5cec0a40dbe7f3304214850c472e2264b10" },
"lazy.nvim": { "branch": "main", "commit": "85c7ff3711b730b4030d03144f6db6375044ae82" },
"mini.icons": { "branch": "main", "commit": "ff2e4f1d29f659cc2bad0f9256f2f6195c6b2428" },
"mini.statusline": { "branch": "main", "commit": "e331175f10d9f400b42523b3890841aba202ce16" },
"oil.nvim": { "branch": "master", "commit": "7e1cd7703ff2924d7038476dcbc04b950203b902" },
"vim-sleuth": { "branch": "master", "commit": "be69bff86754b1aa5adcbb527d7fcd1635a84080" }
}

55
lua/config/keymap.lua Normal file
View File

@@ -0,0 +1,55 @@
vim.keymap.set('n', "-", "<cmd>Oil --float<CR>", { desc ="Enter file explorer (Oil)" })
vim.keymap.set('n', "w", "<cmd>w<CR>", { desc = "Save" } )
vim.keymap.set('n', "<leader>w", "<cmd>w<CR>", { desc = "Save" } )
vim.keymap.set('n', "q", "<cmd>q<CR>", { desc = "Quit without saving" } )
vim.keymap.set('n', "<leader>q", "<cmd>q<CR>", { desc = "Quit without saving" } )
vim.keymap.set('n', "<leader>wq", "<cmd>wq<CR>", { desc = "Save and quit" } )
vim.keymap.set('n', "<leader>qq", "<cmd>q!<CR>", { desc = "Force to quit without saving" } )
-- todo: this is not robust... add autocompletion and verify that file exists
vim.keymap.set("n", "<leader>e", function()
local file_name = vim.fn.input("Open file: ")
if file_name ~= "" then
vim.cmd(":edit " .. file_name)
end
end, { desc = "edit a file"})
vim.keymap.set("n","<leader>ls", "<cmd>ls<CR>", { desc = "list buffers" })
vim.keymap.set("n","<leader>f", "<cmd>bnext<CR>", { desc = "goto next buffers" })
vim.keymap.set("n","<leader>d", "<cmd>bprevious<CR>", { desc = "goto previous buffers" })
vim.keymap.set("n","<leader>c", "<cmd>bd<CR>", { desc = "close buffers" })
vim.keymap.set("n", "<leader>h", function()
local config_path = vim.fn.stdpath('config')
local readme_path = config_path .. '/CHEATSHEET.md'
local buf = vim.fn.bufadd(readme_path)
vim.fn.bufload(buf)
local win = vim.api.nvim_open_win(buf, true, {
relative = 'editor',
width = 80,
height = 20,
col = (vim.o.columns - 80) / 2,
row = (vim.o.lines - 100) / 2,
style = 'minimal'
})
vim.api.nvim_win_set_option(win, 'number', false)
end, { desc = "Open CHEATSHEET.md"})
vim.keymap.set("n", "<leader>hr", function()
local config_path = vim.fn.stdpath('config')
local readme_path = config_path .. '/README.md'
local buf = vim.fn.bufadd(readme_path)
vim.fn.bufload(buf)
local win = vim.api.nvim_open_win(buf, true, {
relative = 'editor',
width = 80,
height = 20,
col = (vim.o.columns - 80) / 2,
row = (vim.o.lines - 100) / 2,
style = 'minimal'
})
vim.api.nvim_win_set_option(win, 'number', false)
end, { desc = "Open CHEATSHEET.md"})

38
lua/config/lazy.lua Normal file
View File

@@ -0,0 +1,38 @@
-- Bootstrap lazy.nvim
local lazypath = vim.fn.stdpath("data") .. "/lazy/lazy.nvim"
if not (vim.uv or vim.loop).fs_stat(lazypath) then
local lazyrepo = "https://github.com/folke/lazy.nvim.git"
local out = vim.fn.system({ "git", "clone", "--filter=blob:none", "--branch=stable", lazyrepo, lazypath })
if vim.v.shell_error ~= 0 then
vim.api.nvim_echo({
{ "Failed to clone lazy.nvim:\n", "ErrorMsg" },
{ out, "WarningMsg" },
{ "\nPress any key to exit..." },
}, true, {})
vim.fn.getchar()
os.exit(1)
end
end
vim.opt.rtp:prepend(lazypath)
-- Make sure to setup `mapleader` and `maplocalleader` before
-- loading lazy.nvim so that mappings are correct.
-- This is also a good place to setup other settings (vim.opt)
vim.g.mapleader = " "
vim.g.maplocalleader = "\\"
-- Setup lazy.nvim
require("lazy").setup({
spec = {
-- import your plugins
{ import = "plugins" },
},
-- Configure any other settings here. See the documentation for more details.
-- colorscheme that will be used when installing plugins.
install = { colorscheme = { "kanagawa" } },
-- automatically check for plugin updates
checker = { enabled = true },
})
require("config.keymap")
require("config.options")

26
lua/config/options.lua Normal file
View File

@@ -0,0 +1,26 @@
vim.o.number = true -- show line numbers
vim.o.relativenumber = true -- show line numbers relative to current line
vim.o.ignorecase = true
vim.o.smartcase = true
-- use vim
--vim.o.expandtab = true -- convert tab to spaces
--vim.o.shiftwidth = 4
vim.o.cursorline = true
vim.o.undofile = true
vim.o.showmode = false
vim.o.signcolumn = "yes"
vim.o.list = true
vim.opt.listchars = { tab = '» ', trail = '·', nbsp = '' }

14
lua/plugins/kanagawa.lua Normal file
View File

@@ -0,0 +1,14 @@
return {
"rebelot/kanagawa.nvim", opt = {},
config = function()
require("kanagawa").setup({
compile = true,
transparent = true
});
vim.cmd("colorscheme kanagawa");
end,
build = function()
vim.cmd("KanagawaCompile"); -- this line fail at first install
end,
}

View File

@@ -0,0 +1,6 @@
return {
'nvim-mini/mini.statusline', version = "",
opts={},
}

11
lua/plugins/oil.lua Normal file
View File

@@ -0,0 +1,11 @@
return {
'stevearc/oil.nvim',
---@module 'oil'
---@type oil.SetupOpts
opts = {},
-- Optional dependencies
dependencies = { { "nvim-mini/mini.icons", opts = {} } },
-- dependencies = { "nvim-tree/nvim-web-devicons" }, -- use if you prefer nvim-web-devicons
-- Lazy loading is not recommended because it is very tricky to make it work correctly in all situations.
lazy = false,
}

3
lua/plugins/sleuth.lua Normal file
View File

@@ -0,0 +1,3 @@
return {
"tpope/vim-sleuth"
}