Skip to content

Instantly share code, notes, and snippets.

@vodrazka
Created January 13, 2024 10:36
Show Gist options
  • Save vodrazka/8ad9a8669c15cb85985788ca8bf61b3e to your computer and use it in GitHub Desktop.
Save vodrazka/8ad9a8669c15cb85985788ca8bf61b3e to your computer and use it in GitHub Desktop.
neovim vanilla single file config
vim.g.mapleader = " "
vim.keymap.set('n', '<leader>.', ":set list!<CR>", { desc = "Toggle whitespaces"})
vim.keymap.set('n', '<leader>,', ":set hls!<CR>", { desc = "Toggle highlight search"})
vim.keymap.set('n', '<leader>j', ":bprevious<CR>", { desc = "Buffer previous"})
vim.keymap.set('n', '<leader>k', ":bnext<CR>", { desc = "Buffer next"})
vim.keymap.set('n', '<leader>l', ":buffers<CR>", { desc = "Buffer next"})
vim.keymap.set('n', '<leader>x', ":bp<bar>sp<bar>bn<bar>bd<CR>", { desc = "Buffer delete"}) --delete but do not exit, strange that vim closes the windows by default...
vim.keymap.set('n', '<leader>t', ":tabnew<CR>", { desc = "Tab new"})
vim.cmd.colorscheme "koehler"
local opt = vim.opt
-- basics
vim.api.nvim_create_autocmd({ "BufWinEnter" }, { command = "set formatoptions-=o" }) --do not add comments from normal mode (o,O) - bug https://github.com/nvim-lualine/lualine.nvim/issues/733
vim.api.nvim_create_autocmd({ "BufWinEnter" }, { command = "set formatoptions-=r" }) --do not add comments from normal mode (o,O) - bug https://github.com/nvim-lualine/lualine.nvim/issues/733
-- toot
vim.opt.backupcopy = 'yes'
-- intendation
opt.completeopt:remove "preview"
opt.wrap = false
opt.expandtab = true
opt.tabstop = 2
opt.shiftwidth = 0 -- inherit from tabstop
opt.softtabstop = -1 --inherit from shiftwidth
opt.listchars:append { tab = '<->' }
opt.listchars:append { space = '.' }
opt.listchars:append { nbsp = '␣' }
opt.listchars:append { trail = '-' }
opt.listchars:append { extends = '>' }
opt.listchars:append { precedes = '<' }
opt.listchars:append { eol = '$' }
opt.mouse = ''
opt.signcolumn = 'yes'
-- undo
local prefix = vim.fn.expand("~/.config")
opt.undodir = { prefix .. "/nvim/.undo//" }
opt.undofile = true
opt.directory = { prefix .. "/nvim/.swp//" }
-- terminal
opt.termguicolors = true
-- nu and gutter
opt.number = true
opt.numberwidth = 2
opt.relativenumber = false
opt.cursorline = true
-- fold
opt.foldcolumn = "1"
opt.foldlevel = 99
opt.foldlevelstart = -1
opt.foldenable = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment