cdotfis/dotfiles/.config/nvim/init.vim

121 lines
3.3 KiB
VimL

let mapleader =","
if ! filereadable(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim"'))
echo "Downloading junegunn/vim-plug to manage plugins..."
silent !mkdir -p ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/
silent !curl "https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim" > ${XDG_CONFIG_HOME:-$HOME/.config}/nvim/autoload/plug.vim
autocmd VimEnter * PlugInstall
endif
call plug#begin(system('echo -n "${XDG_CONFIG_HOME:-$HOME/.config}/nvim/plugged"'))
Plug 'tpope/vim-surround'
Plug 'preservim/nerdtree'
Plug 'junegunn/goyo.vim'
Plug 'jreybert/vimagit'
Plug 'vimwiki/vimwiki'
Plug 'vim-airline/vim-airline'
Plug 'tpope/vim-commentary'
Plug 'ap/vim-css-color'
Plug 'farmergreg/vim-lastplace'
Plug 'jiangmiao/auto-pairs'
" Plug 'xuhdev/vim-latex-live-preview', { 'for': 'tex' }
call plug#end()
set bg=dark
set go=a
set mouse=a
set nohlsearch
" set clipboard+=unnamedplus
" Use this one if you want to use Middle click to paste copied text from vim
set clipboard=unnamed
" Use this one if you want to use primary clipboard!
" set clipboard=unnamedplus
" Though for this we need xsel (https://github.com/neovim/neovim/issues/7945)
" colorscheme delek
colorscheme vim
nnoremap c "_c
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set number relativenumber
set softtabstop=4
set shiftwidth=4
set wildmode=longest,list,full
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
map <leader>f :Goyo \| set linebreak<CR>
map <leader>o :setlocal spell! spelllang=en_us<CR>
set splitbelow splitright
map <leader>n :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
let NERDTreeBookmarksFile = stdpath('data') . '/NERDTreeBookmarks'
if !exists('g:airline_symbols')
let g:airline_symbols = {}
endif
let g:airline_symbols.colnr = ' C:'
let g:airline_symbols.linenr = ' L:'
let g:airline_symbols.maxlinenr = '☰ '
" ctrl-w<motion> where motion is h, j, k, or l. Also, you can use ctrl-ww to cycle between them
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
map Q gq
map <leader>s :!clear && shellcheck %<CR>
nnoremap S :%s//g<Left><Left>
map <leader>c :w! \| !compiler "<c-r>%"<CR>
map <leader>p :!opout <c-r>%<CR><CR>
autocmd VimLeave *.tex !texclear %
cabbrev w!! execute 'silent! write !sudo tee % >/dev/null' <bar> edit!
" autocmd BufWritePre * let currPos = getpos(".")
" autocmd BufWritePre * %s/\s\+$//e
" autocmd BufWritePre * %s/\n\+\%$//e
" autocmd BufWritePre *.[ch] %s/\%$/\r/e " add trailing newline for ANSI C standard
" autocmd BufWritePre *neomutt* %s/^--$/-- /e " dash-dash-space signature delimiter in emails
" autocmd BufWritePre * cal cursor(currPos[1], currPos[2])
autocmd BufWritePost *Xresources,*Xdefaults,*xresources,*xdefaults !xrdb %
if &diff
highlight! link DiffText MatchParen
endif
let g:livepreview_previewer = 'zathura'
let s:hidden_all = 0
function! ToggleHiddenAll()
if s:hidden_all == 0
let s:hidden_all = 1
set noshowmode
set noruler
set laststatus=0
set noshowcmd
else
let s:hidden_all = 0
set showmode
set ruler
set laststatus=2
set showcmd
endif
endfunction
nnoremap <leader>h :call ToggleHiddenAll()<CR>