-- -- My minimal NeoVim Config -- -- I use neovim for most of my text editting needs. When I first moved from -- VScode to editing files exclusively on vim, i was allured by its minimal -- nature. A text editor that runs solely on the terminal - the idea -- captivated me. Around that time, neovim was gaining traction due to it's -- in-built lua support and out of the box LSP capabilities. I moved to neovim -- shortly after. With time, my config files kept getting bigger and bigger. I -- started to miss the time when it was all about a minimal, bloat-free text -- editor. I realized, with a myriad of plugins installed and looking out for -- the next user event to react to, I had slowly recreated the VSCode -- experience I was running away from. -- -- This single config file is my attempt to strip away all that is not needed -- and go back to the basics - a text editter with nothing but only what is -- essential. I have made very careful choice of which plugins to use. There -- is not package manager - I am using the new inbuilt one introduced in -- neovim 0.12. The plugins that are there are present do not depend on a -- thousand other things. There is no auto-autocomplete plugin - I am using -- neovim's internal C-x C-o omnicomplete based autocomplete. This only -- triggers when the user presses C-x C-o. It is connected to the LSP though -- through nvim-lspconfig. -- -- This config file is heavily inspired by Vimothee's youtube video on -- creating a based nvim config. I recommend the reader to check it out for -- sure -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- vim.o.cmdheight = 2 vim.o.shiftwidth = 2 vim.o.tabstop = 2 vim.o.expandtab = true vim.o.smartindent = true vim.o.nu = true vim.o.rnu = true vim.o.cursorline = true vim.o.cursorlineopt = 'line' vim.o.scl = 'yes:1' --signs column vim.o.scrolloff = 5 --keep five lines in context always vim.o.wrap = false vim.o.smartcase = true vim.o.autoread = true vim.o.splitright = true vim.o.splitbelow = true vim.o.modeline = false -- see :h modeline, its kind of a dumb thing vim.o.winborder = "single" vim.o.swapfile = false vim.o.termguicolors = true vim.o.incsearch = true vim.g.mapleader = " " local noremapsilent = { remap = false, silent = true } local noremap = { remap = false } -- arrow keys for resizing vim.keymap.set('n', '', ':resize +5', noremap) vim.keymap.set('n', '', ':resize -5', noremap) vim.keymap.set('n', '', ':vertical resize -5', noremap) vim.keymap.set('n', '', ':vertical resize +5', noremap) -- jj for escape vim.keymap.set('i', 'jj', '', noremapsilent) vim.keymap.set('n', '', ':nohlsearch', noremapsilent) vim.keymap.set({ 'v' }, '<', '', '>gv', noremapsilent) -- exit current mode bindings vim.keymap.set('t', '', '', noremapsilent) -- exit terminal mode vim.keymap.set({ 'c', 'v' }, '', '', noremapsilent) -- exit command/visual mode vim.keymap.set('i', '', '', noremapsilent) -- exit insert mode mode -- terminal bindings vim.keymap.set('n', '/', ':vsp:term', noremapsilent) vim.keymap.set('n', '?', ':sp:term', noremapsilent) -- pane switching bindings vim.keymap.set('n', '', 'h', noremapsilent) vim.keymap.set('n', '', 'j', noremapsilent) vim.keymap.set('n', '', 'k', noremapsilent) vim.keymap.set('n', '', 'l', noremapsilent) -- tab bindings vim.keymap.set({ 'n' }, 't', ':tabnew', { remap = false }) vim.keymap.set({ 'n' }, 'w', ':tabclose', { remap = false }) vim.keymap.set('n', '', ':tabnext', { noremap = true }) vim.keymap.set('n', '', ':tabprevious', { noremap = true }) -- edit and source nvim config vim.keymap.set('n', 's', ':source ~/.config/nvim/init.lua', { remap = false }) vim.keymap.set('n', 'S', ':vsp:e ~/.config/nvim/init.lua', { remap = false }) -- Netrw Explore vim.keymap.set({ 'n' }, 'e', ':Lexplore', { remap = false }) -- vim.keymap.set({ 'x' }, 'ga', '(EasyAlign)', { noremap = true }) -- plugins local gh = function(x) return 'https://github.com/' .. x end vim.pack.add({ gh("nvim-mini/mini.pick"), gh("nvim-mini/mini.icons"), gh("nvim/nvim-lspconfig"), gh("lewis6991/gitsigns.nvim"), }) -- minipick local mp = require "mini.pick" mp.setup() vim.keymap.set({ 'n' }, 'p', mp.builtin.files, { remap = false }) vim.keymap.set({ 'n' }, 'F', mp.builtin.grep_live, { remap = false }) vim.keymap.set({ 'n' }, 'Z', mp.builtin.help, { remap = false }) vim.keymap.set({ 'n' }, '', mp.builtin.resume, { remap = false }) -- gitsigns local gs = require "gitsigns"; gs.setup{ on_attach = function(_) vim.keymap.set('n', 'hp', gs.preview_hunk, { remap = false }) vim.keymap.set('n', 'hi', gs.preview_hunk_inline, {remap = false} ) vim.keymap.set('n', 'ha', gs.stage_hunk, { remap = false }) vim.keymap.set('n', 'hr', gs.reset_hunk, { remap = false }) vim.keymap.set('n', 'hb', gs.blame_line, { remap = false }) vim.keymap.set('v', 'ha', function() gs.stage_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end, {remap = false}) vim.keymap.set('v', 'hr', function() gs.reset_hunk({ vim.fn.line('.'), vim.fn.line('v') }) end, {remap = false}) vim.keymap.set('n', 'hd', gs.diffthis, {remap = false}) vim.keymap.set('n', 'hS', gs.stage_buffer, {remap = false} ) vim.keymap.set('n', 'hR', gs.reset_buffer, {remap = false} ) end } -- LSP -- lua vim.lsp.enable{ "lua_ls", "clangd", "rust-analyzer", } -- fix vim variable for lua vim.lsp.config("lua_ls", { settings = { Lua = { workspace = { library = vim.api.nvim_get_runtime_file("", true), }, }, }, }) vim.keymap.set('n', 'f', vim.lsp.buf.format, { remap = false }) vim.keymap.set('n', 'K', vim.lsp.buf.hover, { remap = false }) vim.keymap.set('n', 'r', vim.diagnostic.open_float, { remap = false })