From 6abaea7a5b60cdf669eb938ff097cd4fae94dd61 Mon Sep 17 00:00:00 2001 From: randomuser Date: Sat, 14 Jan 2023 20:17:04 -0600 Subject: [PATCH] port neovim configuration over --- nvim/init.lua | 137 +++++++++++++++++++++++++++++++++++++++++++++++++ nvim/init.vim | 116 ----------------------------------------- nvim/initq.lua | 37 ------------- 3 files changed, 137 insertions(+), 153 deletions(-) create mode 100644 nvim/init.lua delete mode 100644 nvim/init.vim delete mode 100644 nvim/initq.lua diff --git a/nvim/init.lua b/nvim/init.lua new file mode 100644 index 0000000..b7d3018 --- /dev/null +++ b/nvim/init.lua @@ -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('', ':') + +-- source init.vim +nnoremap('rr', function() + vim.cmd.source('~/.config/nvim/init.lua') +end) +-- edit init.vim +nnoremap('re', function() + vim.cmd.edit('~/.config/nvim/init.lua') +end) +-- openup netrw +nnoremap('fs', function() + vim.cmd.Lexplore() +end) + +inoremap('qp', 'u[s1z=`]au') +inoremap("", "mZ0i`ZlA") + +tnoremap('', '') +-- }}} + +-- 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) +-- }}} diff --git a/nvim/init.vim b/nvim/init.vim deleted file mode 100644 index ea5652d..0000000 --- a/nvim/init.vim +++ /dev/null @@ -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 ym :set number!:set list! -" vimrc thing -nnoremap rr :source ~/.config/nvim/init.vim -nnoremap re :edit ~/.config/nvim/init.vim -" show the file explorer -nnoremap fs :Lexplore -" show the shortcuts in the vimrc -nnoremap ke :e ~/.config/nvim/init.vim ggzR/shortcutsz -" jk to escape insert mode -inoremap jk -" go back to the previous error, then correct -inoremap u[s1z=`]au -inoremap qp u[s1z=`]au -inoremap zgi -inoremap qo zgi -nnoremap zg -tnoremap -nnoremap wl \< -nnoremap wr \> -nnoremap wd - -nnoremap wu + - -nnoremap mk :make:spl:terminal ./main - -nnoremap wI :VimwikiDiaryIndex - -inoremap mZ0i`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 = '' -let g:UltiSnipsJumpForwardTrigger="" -let g:UltiSnipsJumpBackwardTrigger="" -" }}} diff --git a/nvim/initq.lua b/nvim/initq.lua deleted file mode 100644 index c3e083d..0000000 --- a/nvim/initq.lua +++ /dev/null @@ -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('ym', ':set number!:set list!') --- nnoremap('rr', function() vim.cmd.source('~/.config/nvim/init.lua') end) --- nnoremap('re', function() vim.cmd.edit('~/.config/nvim/init.lua') end) -vim.keymap.set('n', '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')