Skip to content

Instantly share code, notes, and snippets.

@pyaf
Last active March 8, 2021 04:46
Show Gist options
  • Save pyaf/8b280b621ee2d2eca82020789e5aaa75 to your computer and use it in GitHub Desktop.
Save pyaf/8b280b621ee2d2eca82020789e5aaa75 to your computer and use it in GitHub Desktop.
My neovim config file
let mapleader =","
call plug#begin('~/.config/nvim/plugged')
Plug 'tpope/vim-surround'
Plug 'scrooloose/nerdtree'
Plug 'mboughaba/i3config.vim'
Plug 'jreybert/vimagit'
Plug 'LukeSmithxyz/vimling'
Plug 'PotatoesMaster/i3-vim-syntax'
Plug 'vimwiki/vimwiki'
Plug 'bling/vim-airline'
Plug 'tpope/vim-commentary'
Plug 'junegunn/goyo.vim'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
Plug 'vim-scripts/vim-auto-save'
Plug 'mhinz/vim-startify'
Plug 'liuchengxu/space-vim-dark'
Plug 'ctrlpvim/ctrlp.vim'
Plug 'powerman/vim-plugin-autosess'
let g:auto_save = 1
let g:auto_save_no_updatetime = 1
let g:auto_save_in_insert_mode = 0
"https://github.com/fisadev/fisa-vim-config/blob/master/.vimrc
"" Override configs by directory
"Plug 'arielrossanigo/dir-configs-override.vim'
"" Better file browser
"Plug 'scrooloose/nerdtree'
"" Code commenter
"Plug 'scrooloose/nerdcommenter'
"" Class/module browser
"Plug 'majutsushi/tagbar'
"" Zen coding
"Plug 'mattn/emmet-vim'
"" Git integration
"Plug 'motemen/git-vim'
"" Tab list panel
"Plug 'kien/tabman.vim'
"" Airline
Plug 'vim-airline/vim-airline-themes'
"" Terminal Vim with 256 colors colorscheme
"Plug 'fisadev/fisa-vim-colorscheme'
"" Consoles as buffers
"Plug 'rosenfeld/conque-term'
"" Pending tasks list
"Plug 'fisadev/FixedTaskList.vim'
"" Surround
"Plug 'tpope/vim-surround'
"" Autoclose
"Plug 'Townk/vim-autoclose'
"" Indent text object
"Plug 'michaeljsmith/vim-indent-object'
"" Indentation based movements
"Plug 'jeetsukumaran/vim-indentwise'
"" Python autocompletion, go to definition.
"Plug 'davidhalter/jedi-vim'
"" Better autocompletion
"Plug 'Shougo/neocomplcache.vim'
"" Snippets manager (SnipMate), dependencies, and snippets repo
"Plug 'MarcWeber/vim-addon-mw-utils'
"Plug 'tomtom/tlib_vim'
"Plug 'honza/vim-snippets'
"Plug 'garbas/vim-snipmate'
"" Git/mercurial/others diff icons on the side of the file lines
"Plug 'mhinz/vim-signify'
"" Automatically sort python imports
"Plug 'fisadev/vim-isort'
"" Drag visual blocks arround
"Plug 'fisadev/dragvisuals.vim'
"" Window chooser
"Plug 't9md/vim-choosewin'
"" Python and other languages code checker
"Plug 'scrooloose/syntastic'
"" Paint css colors with the real color
"Plug 'lilydjwg/colorizer'
"" Ack code search (requires ack installed in the system)
"Plug 'mileszs/ack.vim'
" " YAPF formatter for Python
"Plug 'pignacio/vim-yapf-format'
"Plug 'vim-scripts/IndexedSearch'
"" XML/HTML tags navigation
"Plug 'vim-scripts/matchit.zip'
"" Gvim colorscheme
"Plug 'vim-scripts/Wombat'
" Yank history navigation
"Plug 'vim-scripts/YankRing.vim'
call plug#end()
set bg=dark
set mouse=a
set nohlsearch
set clipboard=unnamedplus
" Some basics:
set nocompatible
filetype plugin on
syntax on
set encoding=utf-8
set number relativenumber
" Enable autocompletion:
set wildmode=longest,list,full
" Disables automatic commenting on newline:
autocmd FileType * setlocal formatoptions-=c formatoptions-=r formatoptions-=o
" Goyo plugin makes text more readable when writing prose:
map <leader>f :Goyo \| set linebreak<CR>
" Spell-check set to <leader>o, 'o' for 'orthography':
map <leader>o :setlocal spell! spelllang=en_us<CR>
" Splits open at the bottom and right, which is non-retarded, unlike vim defaults.
set splitbelow splitright
" Nerd tree
map <C-n> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
" Shortcutting split navigation, saving a keypress:
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" Check file in shellcheck:
map <leader>s :!clear && shellcheck %<CR>
" Replace all is aliased to S.
nnoremap S :%s//g<Left><Left>
" Open corresponding .pdf/.html or preview
"map <leader>p :!opout <c-r>%<CR><CR>
" Runs a script that cleans out tex build files whenever I close out of a .tex file.
autocmd VimLeave *.tex !texclear %
" Ensure files are read as what I want:
let g:vimwiki_ext2syntax = {'.Rmd': 'markdown', '.rmd': 'markdown','.md': 'markdown', '.markdown': 'markdown', '.mdown': 'markdown'}
let g:vimwiki_list = [{'path': '~/vimwiki', 'syntax': 'markdown', 'ext': '.md'}]
autocmd BufRead,BufNewFile /tmp/calcurse*,~/.calcurse/notes/* set filetype=markdown
autocmd BufRead,BufNewFile *.ms,*.me,*.mom,*.man set filetype=groff
autocmd BufRead,BufNewFile *.tex set filetype=tex
" Copy selected text to system clipboard (requires gvim/nvim/vim-x11 installed):
vnoremap <C-c> "+y
map <C-p> "+P
" Enable Goyo by default for mutt writting
" Goyo's width will be the line limit in mutt.
autocmd BufRead,BufNewFile /tmp/neomutt* let g:goyo_width=150
autocmd BufRead,BufNewFile /tmp/neomutt* :Goyo
" Automatically deletes all trailing whitespace on save.
autocmd BufWritePre * %s/\s\+$//e
" When shortcut files are updated, renew bash and ranger configs with new material:
autocmd BufWritePost ~/.bmdirs,~/.bmfiles !shortcuts
" Run xrdb whenever Xdefaults or Xresources are updated.
autocmd BufWritePost ~/.Xresources,~/.Xdefaults !xrdb %
" Navigating with guides
inoremap <leader><leader> <Esc>/<++><Enter>"_c4l
vnoremap <leader><leader> <Esc>/<++><Enter>"_c4l
map <leader><leader> <Esc>/<++><Enter>"_c4l
" Commenting using commentary
" nmap <C+/> <Plug>Commentary
" xmap <C+/> <Plug>Commentary
" Powerline
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=4
" when indenting with '>', use 4 spaces width
set shiftwidth=4
" On pressing tab, insert 4 spaces
set expandtab
let g:goyo_width = 120
let g:goyo_height = 100
set backupdir=~/.vimtmp//,.
set directory=~/.vimtmp//,.
" fold and unfold python functions, copied from SO
set foldmethod=indent
set foldnestmax=2
set nofoldenable
nnoremap <space> za
vnoremap <space> zf
nnoremap gb :ls<cr>:b<space>
map ,p oimport pdb; pdb.set_trace()<ESC>
" https://www.mattlayman.com/blog/2019/supercharging-vim-navigate-files-instantly/
if executable('rg')
let g:ctrlp_user_command = 'rg %s --files --hidden --color=never --glob ""'
endif
nnoremap <Leader>b :CtrlPBuffer<CR>
@pyaf
Copy link
Author

pyaf commented Jun 16, 2020

Clone this config file:

mkdir -p ~/.config/nvim

wget -O ~/.config/nvim/init.vim https://gist.githubusercontent.com/pyaf/8b280b621ee2d2eca82020789e5aaa75/raw/1b7bd68f5311209f2b3d253bb9799871cdba5a64/init.vim

# Install vim plug:

sh -c 'curl -fLo "${XDG_DATA_HOME:-$HOME/.local/share}"/nvim/site/autoload/plug.vim --create-dirs \
       https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim'

# Open vim, run following cmd to install all the plugins:

:PlugInstall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment