started migrating neovim to init.lua.

refs #3
This commit is contained in:
Gabe Venberg 2021-09-06 23:07:40 -05:00
parent 8d4aa86992
commit d8d5296ad2
5 changed files with 131 additions and 37 deletions

View file

@ -0,0 +1,9 @@
"TODO: cleanup this function!
function! Minimal_foldtext()
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '+' . v:folddashes . '| ' . printf("%10S" , lines_count) . ' lines |'
let line_level_text = '| ' . printf("%8S" , 'level ' . v:foldlevel) . ' |'
let fold_text_end = line_level_text . repeat('-',8)
let fold_text_length = strlen(lines_count_text . fold_text_end) + &foldcolumn
return lines_count_text . repeat('-' , winwidth(0) - fold_text_length - 4) . fold_text_end
endfunction

View file

@ -0,0 +1,53 @@
--set some aliases to make typing this faster.
local cmd=vim.cmd
local opt=vim.opt
local fn=vim.fn
--source any legacy code that I havent ported to lua yet.
cmd([[source ~/.config/nvim/legacy.vimrc]])
--options using vim.opt (aliased, of course.)
opt.lazyredraw=true
opt.autoread=true
opt.swapfile=false
opt.history=500
opt.formatoptions='rojq'
--disable hard text wrapping, will only wrap visually.
opt.textwidth=0
opt.wrapmargin=0
opt.wrap=true
opt.linebreak=true
opt.breakindent=true
--add ruler to side of screen.
opt.number=true
--displays cordinates of your cursor in statusbar
opt.ruler=true
--always leave 5 cells between cursor and side of window.
opt.scrolloff=5
opt.sidescrolloff=5
--better command line completion
opt.wildmenu=true
--ignore case in search if search is all lowercase.
opt.ignorecase=true
opt.smartcase=true
--show unfinished commands in statusbar.
opt.showcmd=true
--regex stuff
opt.magic=true
--always have a status line
opt.laststatus=2
--tab stuff
opt.tabstop=4
opt.shiftwidth=4
opt.autoindent=true
--highlight search results as you type.
opt.hlsearch=true
opt.incsearch=true
--foling stuff
cmd([[source ~/.config/nvim/foldtext.vimrc]])
opt.foldmethod='indent'
opt.foldtext='minimal_foldtext()'
opt.fillchars='stl:=,stlnc: ,vert:|,fold:-'
opt.foldcolumn='4'
opt.foldenable=true
opt.foldminlines=2
opt.foldignore=''

View file

@ -0,0 +1,61 @@
"Customized vim/neovim config
"Copyright 2018 Gabe Venberg
"This program is free software: you can redistribute it and/or modify
"it under the terms of the GNU General Public License as published by
"the Free Software Foundation, either version 3 of the License, or
"(at your option) any later version.
"
"This program is distributed in the hope that it will be useful,
"but WITHOUT ANY WARRANTY; without even the implied warranty of
"MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
"GNU General Public License for more details.
"
"You should have received a copy of the GNU General Public License
"along with this program. If not, see <http://www.gnu.org/licenses/>.
filetype plugin on
"useful keybinds
let mapleader = "\\"
"spell checking
"toggle spell checking
noremap <leader>ss :setlocal spell!<CR>
"splitting panels with <leader>| or -
nnoremap <leader>\| :vs<Enter>
nnoremap <leader>\- :sp<Enter>
" shortcuts using leader
" noremap <leader>sn ]s
" noremap <leader>sp [s
" noremap <leader>s? z=
"navigating splits: Control+hjkl will move from split to split
nnoremap <C-h> <C-w>h
nnoremap <C-j> <C-w>j
nnoremap <C-k> <C-w>k
nnoremap <C-l> <C-w>l
"command mode keybinds
"w!! writes using sudo
"cnoremap w!! w !sudo tee % >/dev/null
"highlighting/colour stuff
"sets the colorscheme. to get a list of the available colors, do :colorscheme <Space> <C-d>
colorscheme ron
syntax enable
"<leader> L clears the search highlighting
noremap <leader>l :nohls<CR>
"neovim stuff
" if has('nvim')
" set guicursor=
" endif
"folding stuff TODO: implement other folding methods.
"spacebar opens or closes a fold in normal mode
noremap <Space> za

View file

@ -15,7 +15,7 @@
"along with this program. If not, see <http://www.gnu.org/licenses/>. "along with this program. If not, see <http://www.gnu.org/licenses/>.
"this sets what sort of folding method to use. "this sets what sort of folding method to use.
let foldtype="basicindent" let foldtype="indent"
set lazyredraw set lazyredraw
set autoread set autoread
set history=5000 set history=5000
@ -116,39 +116,3 @@ set noswapfile "disables creation of swap files
"<leader> L clears the search highlighting "<leader> L clears the search highlighting
noremap <leader>l :nohls<CR> noremap <leader>l :nohls<CR>
"neovim stuff
if has('nvim')
set guicursor=
endif
"folding stuff TODO: implement other folding methods.
"give a bit of margin space for fold number
set foldcolumn=4
set foldenable
"set the minimum number of screen lines for a fold to be closable.
set foldminlines=3
"spacebar opens or closes a fold in normal mode
noremap <Space> za
"indent folding: really basic fold method. eventually I may make some custom folds, but with the foldtext fixed a bit, this shouldn't annoy me too much.
if foldtype ==# "basicindent"
"make vim fold automatically based on indentation.
set foldmethod=indent
"make sure that comment are counted in indent folding!
set foldignore=
set fillchars="fold:-"
"set the fold text for this method, in most cases, the line just above our fold is what we want, so we wont put any text into it. just level and linecount.
function! Minimal_foldtext()
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '+' . v:folddashes . '| ' . printf("%10S" , lines_count) . ' lines |'
let line_level_text = '| ' . printf("%8S" , 'level ' . v:foldlevel) . ' |'
let fold_text_end = line_level_text . repeat('-',8)
let fold_text_length = strlen(lines_count_text . fold_text_end) + &foldcolumn
return lines_count_text . repeat('-' , winwidth(0) - fold_text_length - 4) . fold_text_end
endfunction
set foldtext=Minimal_foldtext()
endif

View file

@ -24,6 +24,8 @@
<li><a href="https://docs.python.org/3/library/index.html">The Python Standard Library</a> <li><a href="https://docs.python.org/3/library/index.html">The Python Standard Library</a>
<li><a href="https://docs.python.org/3/howto/logging.html">Logging HOWTO</a> <li><a href="https://docs.python.org/3/howto/logging.html">Logging HOWTO</a>
<li><a href="https://docs.python.org/3/howto/functional.html">Functional Programming HOWTO</a> <li><a href="https://docs.python.org/3/howto/functional.html">Functional Programming HOWTO</a>
<li><a href="https://pymotw.com/3/index.html">Python 3 Module of the Week</a>
<li><a href="http://www.mypy-lang.org/">mypy - Optional Static Typing for Python</a>
<!--End of section (do not delete this comment)--> <!--End of section (do not delete this comment)-->
</ul> </ul>
<h2>git</h2> <h2>git</h2>
@ -31,5 +33,10 @@
<li><a href="https://git-scm.com/doc">Git Documentation</a> <li><a href="https://git-scm.com/doc">Git Documentation</a>
<!--End of section (do not delete this comment)--> <!--End of section (do not delete this comment)-->
</ul> </ul>
<h2>Lua</h2>
<ul>
<li><a href="https://www.lua.org/manual/5.1/">Lua 5.1 Reference Manual</a>
<!--End of section (do not delete this comment)-->
</ul>
</body> </body>
</html> </html>