--[[ General --]] -- Lines of history vim.opt.history = 500 -- Line numbers vim.opt.nu = false -- Autoread when file is changed outside vim vim.opt.autoread = true -- Use a mapleader --vim.opt.mapleader = "," vim.g.mapleader = "," -- Fast saving map('n', 'w', ':w!', silentnoremap) -- Convenient sudo saving of file vim.api.nvim_create_user_command( 'W', 'w !sudo tee % > /dev/null', {bang=true, desc='Save file using sudo'} ) -- Disable the auto line wrap vim.cmd [[ set formatoptions-=t ]] --[[ VIM User interface --]] -- Set 3 lines to the cursor - when moving vertically using j/k vim.opt.so = 3 -- set WildMenu --vim.opt.wildmenu = true -- Ignore compiled files vim.opt.wildignore = '*.o,*~,*.pyc' vim.opt.wildignore:append('*/.git/*,*/.hg/*,*/.svn/*,*/.DS_Store') -- Always show current position --vim.opt.ruler = true -- Hide buffers when they are abandoned vim.opt.hid = true -- Make backspace function normally vim.opt.backspace = 'eol,start,indent' vim.opt.whichwrap:append('<,>,h,l') -- Ignore case when searching vim.opt.ignorecase = true -- Be smart about cases when searching -- If search has uppercases, then we want to respect case vim.opt.smartcase = true -- Highlight search results vim.opt.hlsearch = true -- Make search act like search in modern browsers vim.opt.incsearch = true -- Turn on "magic" for regular expressions vim.opt.magic = true -- Show matching brackets when cursor is over one vim.opt.showmatch = true vim.opt.mat = 2 -- Left column option, used to have it at 1 to always show it. But Gitsigns is not using it anyway vim.opt.foldcolumn = '0' -- Show leader commands vim.opt.showcmd = true -- Show colour column vim.opt.colorcolumn = '80,120' vim.cmd [[ highlight ColorColumn ctermbg=16 ]] -- Colorscheme -- default vim.cmd [[ colorscheme default ]] vim.cmd [[ set background=light ]] -- Workaround for gutter color vim.cmd [[ highlight! link SignColumn LineNr autocmd ColorScheme * highlight! link SignColumn LineNr ]] -- Change git colors --vim.api.nvim_set_hl(0, "DiffAdd", {fg = "#bada9f", bg = "None"}) --vim.api.nvim_set_hl(0, "DiffChange", {fg = "Purple", bg = "None"}) --vim.api.nvim_set_hl(0, "DiffDelete", {fg = "Red", bg = "None"}) --vim.api.nvim_set_hl(0, "DiffText", {fg = "Yellow", bg = "None"}) -- Set utf8 as standard encoding vim.opt.encoding = 'utf8' -- Use Unix as the standard file type vim.opt.ffs = 'unix,dos,mac' --[[ Files, backups and undo --]] vim.opt.swapfile = false --[[ Text, tab and indent related --]] -- Use spaces instead of tabs vim.opt.expandtab = true -- Be smart when using tabs vim.opt.smarttab = true -- 1 tab is 4 spaces vim.opt.shiftwidth = 4 vim.opt.tabstop = 4 vim.opt.softtabstop = 4 -- Auto indent vim.opt.ai = true -- Smart indent vim.opt.si = true -- Wrap lines vim.opt.wrap = true --[[ Visual mode related --]] map('v', ' *', ':call VisualSelection("","")/=@/', silentnoremap) map('v', ' #', ':call VisualSelection("","")?=@/', silentnoremap) --[[ Moving around, tabs, windows and buffers --]] -- Disable highlight when is pressed map('n', '', ':noh', silentnoremap) -- Smart way to move between windows map('', '', 'j', silentnoremap) map('', '', 'k', silentnoremap) map('', '', 'h', silentnoremap) map('', '', 'l', silentnoremap) -- Close current buffer map('n', 'bd', ':Bclose:tabclosegT', silentnoremap) -- Close all buffers map('n', 'ba', ':bufdo bd', silentnoremap) -- Navigate buffers map('n', 'l', ':bnext', silentnoremap) map('n', 'h', ':bprevious', silentnoremap) -- Tab commands map('n', 'tn', ':tabnew', silentnoremap) map('n', 'to', ':tabonly', silentnoremap) --map('n', 'tc', ':tabclose', silentnoremap) map('n', 'tm', ':tabmove', silentnoremap) map('n', 't', ':tabnext', silentnoremap) -- Switch CWD to directory of the open buffer map('n', 'cd', ':cd %:p:h:pwd 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif ]] -- Make mouse work nice with tmux vim.opt.mouse = 'a' --[[ Status Line --]] -- Always show status line vim.opt.laststatus = 2 --[[ Mappings --]] -- Move a line of text using ALT+[jk] map('n', '', 'mz:m+`z', silentnoremap) map('n', '', 'mz:m-2`z', silentnoremap) map('v', '', ":m'>+`mzgv`yo`z", silentnoremap) map('v', '', ":m'<-2`>my`', '', silentnoremap) map('n', '', '', silentnoremap) map('v', '', '', silentnoremap) map('v', '', '', silentnoremap) end -- Interact with system clipboard map('v', 'y', '"+y', noremap) map('n', 'Y', '"+yg_', noremap) map('n', 'y', '"+y', noremap) map('v', 'p', '"+p', noremap) map('v', 'P', '"+P', noremap) map('n', 'p', '"+p', noremap) map('n', 'P', '"+P', noremap) -- Delete trailing whitespace on save --vim.api.nvim_create_autocmd("BufWritePre", { -- pattern = { "*" }, -- command = [[%s/\s\+$//e]] --}) --[[ Misc --]] -- Scribble buffer map('n', 'q', ':e ~/buffer', silentnoremap) -- Toggle paste mode map('n', 'pp', ':setlocal paste!', silentnoremap) -- Send file-title to tmux vim.opt.titlestring = [[%f %h%m%r%w%{v:progname} (%{tabpagenr()} of %{tabpagenr('$')}})]] vim.opt.title = true --[[ Debugging --]] vim.g.termdebug_popup = 0 vim.g.termdebug_wide = 163 vim.cmd([[:packadd termdebug]]) -- This is to get rid of weird artifacts with text showing up inside buffer. vim.opt.title = false