Skip to content

Instantly share code, notes, and snippets.

@JasonThomasData
Created September 5, 2019 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JasonThomasData/c499a7a8e4b173e0b3736408883f06c2 to your computer and use it in GitHub Desktop.
Save JasonThomasData/c499a7a8e4b173e0b3736408883f06c2 to your computer and use it in GitHub Desktop.
Config file for nvim, much smaller than a .vimrc with the same functionality
"////////////////////////////
"// Vim settings
"// No plugins needed ...
set number "Show line numbers
set linebreak " Break lines at word (requires Wrap lines)
set showbreak=+++ " Wrap-broken line prefix
set textwidth=100 " Line wrap (number of cols)
set showmatch " Highlight matching brace
"set spell " Enable spell-checking
set visualbell " Use visual bell (no beeping)
set hlsearch " Highlight all search results
set smartcase " Enable smart-case search
"set ignorecase " Always case-insensitive
set incsearch " Searches for strings incrementally
set smartindent " Enable smart-indent
set undolevels=1000 " Number of undo levels
set backspace=indent,eol,start " Backspace behaviour
set ruler " Show row and column ruler information, but doesn't work with YCM
" Visual
set background=dark
highlight Normal ctermfg=white ctermbg=black
syntax enable
" Language specific
set softtabstop=2
set tabstop=4
set shiftwidth=4
set smarttab
set expandtab " spaces instead of tabs
"Unless you're using...
au FileType ruby setlocal tabstop=2 shiftwidth=2 autoindent
au FileType py setlocal autoindent textwidth=79
au FileType cs setlocal tabstop=2 shiftwidth=2
au FileType js setlocal tabstop=1 shiftwidth=2
"This, from here - http://stackoverflow.com/questions/676600/vim-search-and-replace-selected-text -
"lets you highlight some text and replace after hitting ctrl-r
vnoremap <C-r> "hy:%s/<C-r>h//gc<left><left><left>
"This is netrw stuff, allows for having an explorer panel on left and open document on right
let g:netrw_banner = 0
let g:netrw_liststyle = 3
let g:netrw_browse_split = 4
let g:netrw_altv = 1
let g:netrw_winsize = 25
"Autocomplete
"
ino [ []<left>
ino { {}<left>
ino ( ()<left>
ino {<CR> {<CR>}<ESC>O
"////////////////////////////
"// Vim-Plug installs
"To install vim-plug:
" curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
" https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
" From https://github.com/junegunn/vim-plug
" Also do :CocInstall coc-python
call plug#begin('~/.local/share/nvim/plugged')
Plug 'neoclide/coc.nvim' "Alternative to YCM
call plug#end()
"////////////////////////////
"// CtrlP
set autochdir
set tags=tags;
"The experience with CtrlP is enhance with ctags
" sudo apt-get install ctags
"Run ctags -R * at the root directory to generate a tags file.
"For doing Haskell programming, use hasktags:
" sudo apt-get install hasktags
"Run hasktags -c . at root.
"Ctrl ] will take you to a definition file, and adds one to the visited tag stack, and ctrl-o pops one from the stack
function! DoFormatXML()
" save the filetype so we can restore it later
let l:origft = &ft
set ft=
" delete the xml header if it exists. This will
" permit us to surround the document with fake tags
" without creating invalid xml.
1s/<?xml .*?>//e
" insert fake tags around the entire document.
" This will permit us to pretty-format excerpts of
" XML that may contain multiple top-level elements.
0put ='<PrettyXML>'
$put ='</PrettyXML>'
silent %!xmllint --format -
" xmllint will insert an <?xml?> header. it's easy enough to delete
" if you don't want it.
" delete the fake tags
2d
$d
" restore the 'normal' indentation, which is one extra level
" too deep due to the extra tags we wrapped around the document.
silent %<
" back to home
1
" restore the filetype
exe "set ft=" . l:origft
endfunction
com! FormatXML call DoFormatXML()
function! DoFormatJSON()
:%!python -m json.tool
endfunction
com! FormatJSON call DoFormatJSON()
com! FormatJson call DoFormatJSON()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment