port neovim configuration over

This commit is contained in:
randomuser 2023-01-14 20:17:04 -06:00
parent e7a152dd65
commit 6abaea7a5b
3 changed files with 137 additions and 153 deletions

137
nvim/init.lua Normal file
View File

@ -0,0 +1,137 @@
-- randomuser's
-- _ _ _ _
-- (_)_ __ (_) |_ | |_ _ __ _
-- | | '_ \| | __| | | | | |/ _` |
-- | | | | | | |_ _| | |_| | (_| |
-- |_|_| |_|_|\__(_)_|\__,_|\__,_|
-- helper functions {{{
function nnoremap(l, r)
vim.keymap.set('n', l, r) -- noremap is implied
end
function inoremap(l, r)
vim.keymap.set('i', l, r)
end
function tnoremap(l, r)
vim.keymap.set('t', l, r)
end
-- }}}
-- custom mappings {{{
vim.g.mapleader = ' '
nnoremap(';', ':')
nnoremap(':', ';')
nnoremap('<leader><leader>', ':')
-- source init.vim
nnoremap('<leader>rr', function()
vim.cmd.source('~/.config/nvim/init.lua')
end)
-- edit init.vim
nnoremap('<leader>re', function()
vim.cmd.edit('~/.config/nvim/init.lua')
end)
-- openup netrw
nnoremap('<leader>fs', function()
vim.cmd.Lexplore()
end)
inoremap('qp', '<c-g>u<Esc>[s1z=`]a<c-g>u')
inoremap("<C-a>", "<Esc>mZ0i<Tab><Esc>`ZlA")
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
vim.api.nvim_create_autocmd({"Filetype"}, {
pattern = {"python"},
callback = function()
vim.bo.expandtab = true
vim.bo.tabstop = 4
vim.bo.shiftwidth = 4
end
})
-- }}}
-- vim options {{{
vim.o.compatible = false
vim.o.number = true
vim.o.foldmethod = 'marker'
vim.o.encoding = 'utf8'
vim.o.list = true
vim.o.lcs = 'tab:->,trail:_,eol:^'
vim.o.clipboard = 'unnamedplus'
vim.o.spell = true
vim.o.spelllang = "en_us"
vim.o.title = true
vim.o.ts = 2
vim.o.sw = 2
vim.o.hlsearch = true
vim.o.incsearch = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.inccommand = 'nosplit'
vim.o.hidden = true
vim.opt.path:append {'**'}
vim.cmd.colorscheme('earth')
vim.o.statusline="%f %r%m%q%h%=%y 0x%02B %04l:%03c:%03p"
vim.api.nvim_exec("let &titlestring='%{expand(\"%:p\")}'", true)
-- }}}
-- 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'
use 'vimwiki/vimwiki'
if packer_bootstrap then
require('packer').sync()
end
end)
-- }}}

View File

@ -1,116 +0,0 @@
" randomuser's vimrc
" vim-plug {{{
call plug#begin()
Plug 'tridactyl/vim-tridactyl'
Plug 'vimwiki/vimwiki'
cal plug#end()
" }}}
" misc {{{
nnoremap ; :
nnoremap : ;
let mapleader = " "
set nocompatible
" }}}
" defined settings {{{
set number
set foldmethod=marker
set encoding=utf8
set list
set lcs=tab:->,trail:_,eol:^
set clipboard=unnamedplus
set spell
set spelllang=en_us
set title
set ts=2
set sw=2
set hlsearch
set incsearch
set ignorecase
set smartcase
set inccommand=nosplit
set nocompatible
set hidden
set path+=**
set wildmenu
colorscheme earth
" }}}
" shortcuts {{{
" toggle line numbers and listchars
nnoremap <Leader>ym :set number!<CR>:set list!<CR>
" vimrc thing
nnoremap <Leader>rr :source ~/.config/nvim/init.vim<CR>
nnoremap <Leader>re :edit ~/.config/nvim/init.vim<CR>
" show the file explorer
nnoremap <Leader>fs :Lexplore<CR>
" show the shortcuts in the vimrc
nnoremap <Leader>ke :e ~/.config/nvim/init.vim <CR>ggzR/shortcuts<CR>z<CR>
" jk to escape insert mode
inoremap jk <esc>
" go back to the previous error, then correct
inoremap <C-d> <c-g>u<Esc>[s1z=`]a<c-g>u
inoremap qp <c-g>u<Esc>[s1z=`]a<c-g>u
inoremap <C-s> <Esc>zgi
inoremap qo <Esc>zgi
nnoremap <C-s> zg
tnoremap <Esc> <C-\><C-n>
nnoremap <Leader>wl <C-w>\<
nnoremap <Leader>wr <C-w>\>
nnoremap <Leader>wd <C-w>-
nnoremap <Leader>wu <C-w>+
nnoremap <Leader>mk :make<CR>:spl<CR>:terminal ./main<CR>
nnoremap <Leader>w<Leader>I :VimwikiDiaryIndex<CR>
inoremap <C-a> <Esc>mZ0i<Tab><Esc>`ZlA
" }}}
" autocmds {{{
au Filetype python setl et ts=4 sw=4
function SwapExistsHandler()
silent !vim-swap-handler "%:p"
if v:shell_error == 0
let v:swapchoice='o'
return
elseif v:shell_error == 1
let v:swapchoice='o'
echom "The file has been opened read-only, as there is not another vim instance editing this file."
elseif v:shell_error == 127
echom "The vim-swap-handler command doesn't exist."
else
echom "An unknown error occurred."
endif
endfunction
autocmd SwapExists * call SwapExistsHandler()
au BufWrite bspwmrc !bspc wm -r
au BufWrite sxhkdrc !killall sxhkd -USR1
" }}}
" statusline {{{
set statusline=%f
set statusline+=\
set statusline+=%r%m%q%h
set statusline+=%=
set statusline+=%y\ 0x%02B\ %04l:%03c:%03p
" }}}
" titlebar {{{
let &titlestring='%{expand("%:p")}'
" }}}
" netrw {{{
let g:netrw_banner=0
" }}}
" ultisnips {{{
let g:UltiSnipsExpandTrigger = '<tab>'
let g:UltiSnipsJumpForwardTrigger="<c-b>"
let g:UltiSnipsJumpBackwardTrigger="<c-z>"
" }}}

View File

@ -1,37 +0,0 @@
noremap = { noremap = true }
function nnoremap(l, r)
vim.keymap.set('n', l, r, noremap)
end
vim.env.mapleader = ' '
nnoremap(';', ':')
nnoremap(':', ';')
-- nnoremap('<leader>ym', ':set number!<CR>:set list!<CR>')
-- nnoremap('<leader>rr', function() vim.cmd.source('~/.config/nvim/init.lua') end)
-- nnoremap('<leader>re', function() vim.cmd.edit('~/.config/nvim/init.lua') end)
vim.keymap.set('n', '<leader>rr', function() vim.cmd.source('~/.config/nvim/init.lua') end)
-- conf.nocompatible = true
-- not sure why this does not work
-- will checkout later
vim.o.number = true
vim.o.foldmethod = 'marker'
vim.o.encoding = 'utf8'
vim.o.list = true
vim.o.lcs = 'tab:->,trail:_,eol:^'
vim.o.clipboard = 'unnamedplus'
vim.o.spell = true
vim.o.spelllang = "en_us"
vim.o.title = true
vim.o.ts = 2
vim.o.sw = 2
vim.o.hlsearch = true
vim.o.incsearch = true
vim.o.ignorecase = true
vim.o.smartcase = true
vim.o.inccommand = 'nosplit'
vim.o.hidden = true
vim.opt.path:append {'**'}
vim.cmd.colorscheme('earth')