2023-01-14 20:17:04 -06:00
|
|
|
-- randomuser's
|
|
|
|
-- _ _ _ _
|
|
|
|
-- (_)_ __ (_) |_ | |_ _ __ _
|
|
|
|
-- | | '_ \| | __| | | | | |/ _` |
|
|
|
|
-- | | | | | | |_ _| | |_| | (_| |
|
|
|
|
-- |_|_| |_|_|\__(_)_|\__,_|\__,_|
|
|
|
|
|
|
|
|
-- helper functions {{{
|
2023-01-31 11:28:10 -06:00
|
|
|
local keymapper = vim.keymap
|
|
|
|
local globals = vim.g
|
|
|
|
local opt = vim.o
|
|
|
|
local cmd = vim.cmd
|
2023-01-14 20:17:04 -06:00
|
|
|
function nnoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('n', l, r) -- noremap is implied
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
function inoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('i', l, r)
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
function tnoremap(l, r)
|
2023-01-31 11:28:10 -06:00
|
|
|
keymapper.set('t', l, r)
|
2023-01-14 20:17:04 -06:00
|
|
|
end
|
2023-01-31 11:28:10 -06:00
|
|
|
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- custom mappings {{{
|
2023-01-31 11:28:10 -06:00
|
|
|
globals.mapleader = ' '
|
2023-01-14 20:17:04 -06:00
|
|
|
nnoremap(';', ':')
|
|
|
|
nnoremap(':', ';')
|
|
|
|
nnoremap('<leader><leader>', ':')
|
|
|
|
|
|
|
|
-- source init.vim
|
|
|
|
nnoremap('<leader>rr', function()
|
2023-01-31 11:28:10 -06:00
|
|
|
cmd.source('~/.config/nvim/init.lua')
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
-- edit init.vim
|
|
|
|
nnoremap('<leader>re', function()
|
2023-01-31 11:28:10 -06:00
|
|
|
cmd.edit('~/.config/nvim/init.lua')
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
-- openup netrw
|
|
|
|
nnoremap('<leader>fs', function()
|
2023-01-31 11:28:10 -06:00
|
|
|
cmd.Lexplore()
|
2023-01-14 20:17:04 -06:00
|
|
|
end)
|
|
|
|
|
|
|
|
inoremap('qp', '<c-g>u<Esc>[s1z=`]a<c-g>u')
|
|
|
|
inoremap("<C-a>", "<Esc>mZ0i<Tab><Esc>`ZlA")
|
2023-03-24 10:24:33 -05:00
|
|
|
inoremap('jk', '<Esc>')
|
|
|
|
inoremap('zz', '<Esc>:w!<CR>a')
|
2023-01-14 20:17:04 -06:00
|
|
|
|
|
|
|
tnoremap('<Esc>', '<C-\\><C-n>')
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- autocommands {{{
|
|
|
|
-- swapfile handler
|
|
|
|
vim.api.nvim_create_autocmd({"SwapExists"}, {
|
|
|
|
pattern = {"*"},
|
|
|
|
callback = function()
|
|
|
|
vim.fn.system("vim-swap-handler " .. vim.api.nvim_buf_get_name(0))
|
|
|
|
print(vim.v.shell_error)
|
|
|
|
if (vim.v.shell_error == 0) then
|
|
|
|
vim.v.swapchoice = 'o'
|
|
|
|
print("opened in other place. you should have teleported there")
|
|
|
|
elseif (vim.v.shell_error == 1) then
|
|
|
|
vim.v.swapchoice = 'o'
|
|
|
|
print("file opened readonly. orphaned swap file?")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- autocmds for sxhkd and bspwm config files
|
|
|
|
vim.api.nvim_create_autocmd({"BufWrite"}, {
|
|
|
|
pattern = {"bspwmrc"},
|
|
|
|
callback = function()
|
|
|
|
vim.fn.system("bspc wm -r")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
vim.api.nvim_create_autocmd({"BufWrite"}, {
|
|
|
|
pattern = {"sxhkdrc"},
|
|
|
|
callback = function()
|
|
|
|
vim.fn.system("killall sxhkd -USR1")
|
|
|
|
end
|
|
|
|
})
|
|
|
|
|
|
|
|
-- autocmds for python
|
2023-04-02 12:47:07 -05:00
|
|
|
-- vim.api.nvim_create_autocmd({"Filetype"}, {
|
|
|
|
-- pattern = {"python"},
|
|
|
|
-- callback = function()
|
|
|
|
-- vim.bo.expandtab = true
|
|
|
|
-- vim.bo.tabstop = 4
|
|
|
|
-- vim.bo.shiftwidth = 4
|
|
|
|
-- end
|
|
|
|
-- })
|
|
|
|
|
|
|
|
function setTabbing(lang, width)
|
|
|
|
vim.api.nvim_create_autocmd({"Filetype"}, {
|
|
|
|
pattern = {lang},
|
|
|
|
callback = function()
|
|
|
|
vim.bo.expandtab = true
|
|
|
|
vim.bo.tabstop = width
|
|
|
|
vim.bo.shiftwidth = width
|
|
|
|
end
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
|
|
|
setTabbing("python", 4)
|
|
|
|
setTabbing("javascript", 2)
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- vim options {{{
|
2023-01-31 11:28:10 -06:00
|
|
|
opt.compatible = false
|
|
|
|
opt.number = true
|
|
|
|
opt.foldmethod = 'marker'
|
|
|
|
opt.encoding = 'utf8'
|
|
|
|
opt.list = true
|
|
|
|
opt.lcs = 'tab:->,trail:_,eol:^'
|
|
|
|
opt.clipboard = 'unnamedplus'
|
|
|
|
opt.spell = true
|
|
|
|
opt.spelllang = "en_us"
|
|
|
|
opt.title = true
|
|
|
|
opt.ts = 2
|
|
|
|
opt.sw = 2
|
|
|
|
opt.hlsearch = true
|
|
|
|
opt.incsearch = true
|
|
|
|
opt.ignorecase = true
|
|
|
|
opt.smartcase = true
|
|
|
|
opt.inccommand = 'nosplit'
|
|
|
|
opt.hidden = true
|
|
|
|
opt.path = '.,/usr/include,**'
|
2023-01-14 20:17:04 -06:00
|
|
|
vim.cmd.colorscheme('earth')
|
2023-01-31 11:28:10 -06:00
|
|
|
opt.statusline="%f %r%m%q%h%=%y 0x%02B %04l:%03c:%03p"
|
2023-01-14 20:17:04 -06:00
|
|
|
vim.api.nvim_exec("let &titlestring='%{expand(\"%:p\")}'", true)
|
2023-01-31 11:28:10 -06:00
|
|
|
|
|
|
|
globals.vimtex_view_method = 'zathura'
|
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- netrw options {{{
|
|
|
|
globals.netrw_winsize = -28
|
|
|
|
globals.netrw_banner = 0
|
|
|
|
-- for tree view
|
|
|
|
globals.netrw_liststyle = 3
|
|
|
|
-- use previous window to open files
|
|
|
|
globals.netrw_browser_split = 4
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|
|
|
|
|
|
|
|
-- packer.nvim {{{
|
|
|
|
-- taken from packer.nvim readme
|
|
|
|
local ensure_packer = function()
|
|
|
|
local fn = vim.fn
|
|
|
|
local install_path = fn.stdpath('data') .. '/site/pack/packer/start/packer.nvim'
|
|
|
|
if fn.empty(fn.glob(install_path)) > 0 then
|
|
|
|
fn.system({'git', 'clone', '--depth', '1', 'https://github.com/wbthomason/packer.nvim', install_path})
|
|
|
|
vim.cmd [[packadd packer.nvim]]
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
|
|
|
local packer_bootstrap = ensure_packer()
|
|
|
|
|
|
|
|
return require('packer').startup(function(use)
|
|
|
|
use 'wbthomason/packer.nvim'
|
2023-01-31 11:28:10 -06:00
|
|
|
use 'tpope/vim-surround'
|
|
|
|
use 'tpope/vim-commentary'
|
|
|
|
use 'tpope/vim-fugitive'
|
|
|
|
use 'https://github.com/vimwiki/vimwiki.git'
|
|
|
|
use 'lervag/vimtex'
|
2023-01-14 20:17:04 -06:00
|
|
|
|
|
|
|
if packer_bootstrap then
|
|
|
|
require('packer').sync()
|
|
|
|
end
|
2023-01-31 11:28:10 -06:00
|
|
|
end);
|
2023-01-14 20:17:04 -06:00
|
|
|
-- }}}
|