Skip to content

Instantly share code, notes, and snippets.

@ryochack
Last active June 1, 2026 23:51
Show Gist options
  • Select an option

  • Save ryochack/d15ba7ae0edc717cc3b62d6854248d21 to your computer and use it in GitHub Desktop.

Select an option

Save ryochack/d15ba7ae0edc717cc3b62d6854248d21 to your computer and use it in GitHub Desktop.
---- BASE SETTINGS ----
do --- vim.opt ---
local opt = vim.opt
for k, v in pairs({
-- IMPORT SETTINGS --
modeline = false,
modelines = 0,
-- FILE --
confirm = true,
-- DIAPLAY --
termguicolors = true,
title = false,
number = true,
relativenumber = false,
signcolumn = "yes",
wrap = true,
linebreak = true,
showbreak = "↪ ",
-- showbreak = "» ",
breakindent = true,
-- breakindentopt = "sbr",
showmatch = true, -- -> matchparen on nvim
list = true,
listchars = {
tab = "» ",
trail = "·",
extends = "›",
precedes = "‹",
},
display = { "lastline", "uhex", "msgsep" },
diffopt = { "internal", "filler", "closeoff", "iwhite" },
inccommand = "split",
-- STATUS LINE --
laststatus = 2,
showmode = true,
showcmd = true,
cmdheight = 1,
-- FOLDING --
foldenable = false,
foldmethod = "expr",
foldlevel = 100,
foldcolumn = "1",
foldnestmax = 3,
foldminlines = 1,
-- SEARCHING --
wrapscan = false,
ignorecase = true,
smartcase = true,
incsearch = true,
hlsearch = true,
-- MOVING --
scrolloff = 3,
sidescrolloff = 3,
virtualedit = "block",
whichwrap = "b,s,h,l,<,>,[,]",
mouse = "a",
-- BUFFER --
splitright = true,
splitbelow = true,
-- EDITTING --
backspace = { "indent", "eol", "start" },
autoread = true,
hidden = true,
formatoptions = "roqlm",
clipboard = "unnamedplus",
fileformats = { "unix", "dos" },
-- INDENT --
smartindent = true,
autoindent = true,
expandtab = true,
shiftwidth = 2,
tabstop = 2,
softtabstop = 0,
-- IME --
iminsert = 0,
imsearch = 0,
-- BACKUP / RESTORE --
swapfile = false,
backup = false,
writebackup = true,
undofile = true,
undodir = vim.fn.stdpath("state") .. "/undo",
shada = "'100,<1000,s100,/100",
shadafile = vim.fn.stdpath("state") .. "/shada/main.shada",
-- NOTIFICATIONS --
belloff = "all",
-- GREP (ripgrep) --
grepprg = "rg --vimgrep --smart-case",
grepformat = "%f:%l:%c:%m",
-- COMPLEMENTS --
wildmenu = true,
history = 1000,
complete = ".,w,b,u,t,i",
completeopt = { "menu", "menuone", "noselect" },
pumheight = 10,
omnifunc = "v:lua.vim.lsp.omnifunc",
suffixes = {
".bak", "~", ".swp",
".o", ".obj", ".out", ".elf", ".self",
},
}) do
opt[k] = v
end
end
-- Auto create target directory if it is not exists
local group = vim.api.nvim_create_augroup("AutoMkdir", { clear = true })
vim.api.nvim_create_autocmd("BufWritePre", {
group = group,
callback = function(args)
local file = vim.api.nvim_buf_get_name(args.buf)
local dir = vim.fs.dirname(file)
if dir and vim.fn.isdirectory(dir) == 0 then
vim.fn.mkdir(dir, "p")
end
end,
})
-- Highlight cursorline on only current buffer
vim.opt.cursorline = false
-- vim.api.nvim_set_hl(0, "CursorLine", { underline = true })
vim.api.nvim_create_autocmd({ "WinEnter", "BufEnter" }, {
callback = function()
vim.wo.cursorline = true
end,
})
vim.api.nvim_create_autocmd({ "WinLeave", "BufLeave" }, {
callback = function()
vim.wo.cursorline = false
end,
})
---- KEY BINDIGS ----
do
vim.g.mapleader = "\\"
local keymap = vim.keymap.set
-- Moving --
keymap("n", "j", "gj")
keymap("n", "k", "gk")
keymap("n", "gj", "j")
keymap("n", "gk", "k")
keymap({"n", "v"}, "<C-a>", "^")
keymap({"n", "v"}, "<C-e>", "$")
keymap({"i", "c"}, "<C-a>", "<Home>")
keymap({"i", "c"}, "<C-e>", "<End>")
-- Turn off highlight of searching results --
keymap("n", "<Esc><Esc>", "<cmd>nohlsearch<CR>", { silent = true })
-- Get path of current directory --
keymap("c", "<C-x>",
function()
return vim.fn.expand("%:p:h") .. "/"
end, { expr = true })
end
vim.api.nvim_create_autocmd("InsertLeave", {
callback = function()
vim.opt.iminsert = 0
end
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment