Start new neovim config
Add basic options and keymaps
This commit is contained in:
parent
ab2c05ee4d
commit
b149a776b0
6 changed files with 118 additions and 0 deletions
nvim
4
nvim/after/ftplugin/lua.lua
Normal file
4
nvim/after/ftplugin/lua.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
local opt = vim.opt_local
|
||||
|
||||
opt.softtabstop = 2
|
||||
opt.shiftwidth = 2
|
4
nvim/init.lua
Normal file
4
nvim/init.lua
Normal file
|
@ -0,0 +1,4 @@
|
|||
require("config.options")
|
||||
require("config.keymaps")
|
||||
|
||||
require("config.lazy")
|
40
nvim/lua/config/keymaps.lua
Normal file
40
nvim/lua/config/keymaps.lua
Normal file
|
@ -0,0 +1,40 @@
|
|||
local set = vim.keymap.set
|
||||
vim.g.mapleader = " "
|
||||
|
||||
set("i", "jk", "<ESC>")
|
||||
set("i", "kj", "<ESC>")
|
||||
|
||||
set({"n", "x"}, "j", [[v:count == 0 ? "gj" : "j"]], { expr = true })
|
||||
set({"n", "x"}, "k", [[v:count == 0 ? "gk" : "k"]], { expr = true })
|
||||
|
||||
set({"n", "x"}, ";", ":")
|
||||
set({"n", "x"}, ":", ";")
|
||||
|
||||
set({"n", "x"}, "gy", "\"+y")
|
||||
set("n", "gp", "\"+p")
|
||||
|
||||
set("n", "n", "nzz")
|
||||
set("n", "N", "Nzz")
|
||||
|
||||
set("n", "<c-u>", "<c-u>zz")
|
||||
set("n", "<c-d>", "<c-d>zz")
|
||||
|
||||
set("n", "<leader>w", "<c-w>")
|
||||
|
||||
set("n", "<cr>", function()
|
||||
if vim.v.hlsearch == 1 then
|
||||
vim.cmd.nohlsearch()
|
||||
return ""
|
||||
else
|
||||
return "<cr>"
|
||||
end
|
||||
end, { expr = true })
|
||||
|
||||
vim.api.nvim_create_autocmd("Filetype", {
|
||||
pattern = "lua",
|
||||
group = vim.api.nvim_create_augroup("RunLua", { clear = true }),
|
||||
callback = function()
|
||||
vim.keymap.set("n", "<leader>x", "<cmd>. lua<cr>", { buffer = true })
|
||||
vim.keymap.set("n", "<leader><leader>x", "<cmd>% lua<cr>", { buffer = true })
|
||||
end,
|
||||
})
|
24
nvim/lua/config/lazy.lua
Normal file
24
nvim/lua/config/lazy.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
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)
|
||||
|
||||
require("lazy").setup({
|
||||
spec = {
|
||||
{ "ellisonleao/gruvbox.nvim", config = function() vim.cmd.colorscheme "gruvbox" end },
|
||||
|
||||
{ import = "config.plugins" }
|
||||
},
|
||||
install = { colorscheme = { "gruvbox" } }
|
||||
})
|
37
nvim/lua/config/options.lua
Normal file
37
nvim/lua/config/options.lua
Normal file
|
@ -0,0 +1,37 @@
|
|||
local opt = vim.opt
|
||||
|
||||
opt.expandtab = true
|
||||
opt.shiftwidth = 4
|
||||
opt.smartindent = true
|
||||
opt.softtabstop = 4
|
||||
|
||||
opt.hidden = true
|
||||
opt.swapfile = false
|
||||
|
||||
opt.splitright = true
|
||||
opt.splitbelow = true
|
||||
|
||||
opt.number = true
|
||||
opt.relativenumber = true
|
||||
|
||||
opt.cursorline = true
|
||||
opt.colorcolumn = "80"
|
||||
opt.signcolumn = "yes"
|
||||
opt.laststatus = 3
|
||||
|
||||
opt.ignorecase = true
|
||||
opt.inccommand = 'nosplit'
|
||||
opt.incsearch = true
|
||||
opt.smartcase = true
|
||||
|
||||
opt.scrolloff = 5
|
||||
opt.termguicolors = true
|
||||
opt.timeoutlen = 500
|
||||
opt.wrap = false
|
||||
|
||||
opt.list = true
|
||||
opt.listchars = { eol = "↲", nbsp = '␣', tab = '» ', trail = '·' }
|
||||
opt.fillchars = { eob = " " }
|
||||
|
||||
opt.exrc = true
|
||||
opt.mouse = "a"
|
9
nvim/lua/config/plugins/mini.lua
Normal file
9
nvim/lua/config/plugins/mini.lua
Normal file
|
@ -0,0 +1,9 @@
|
|||
return {
|
||||
{
|
||||
"echasnovski/mini.nvim",
|
||||
config = function()
|
||||
local statusline = require "mini.statusline"
|
||||
statusline.setup { use_icons = true }
|
||||
end
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue