Skip to content

Instantly share code, notes, and snippets.

@JasonThomasData
Last active April 30, 2019 04:54
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/97eae2fc6c6ca74fc51f0fec63ef9371 to your computer and use it in GitHub Desktop.
Save JasonThomasData/97eae2fc6c6ca74fc51f0fec63ef9371 to your computer and use it in GitHub Desktop.
My .vimrc - putting this here so it's easy to grab
"////////////////////////////
"// 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
"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
"////////////////////////////
"// Vundle installs
"To install vundle:
"git clone https://github.com/VundleVim/Vundle.vim.git ~/.vim/bundle/Vundle.vim
"YouCompleteMe require you to install vim, do:
"https://github.com/Valloric/YouCompleteMe/wiki/Building-Vim-from-source
"https://github.com/Valloric/YouCompleteMe
"To install these plugins, at terminal do `vim +PluginInstall +qall`, or in vim do `:PluginInstall`
set nocompatible
filetype off
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
Plugin 'VundleVim/Vundle.vim' "Apparently Vundle manages Vundle. OK
Plugin 'Valloric/YouCompleteMe'
Plugin 'kien/ctrlp.vim' "Best used with ctags/hasktags - install at terminal
Plugin 'mxw/vim-jsx' "For jsx, react
Plugin 'pangloss/vim-javascript' "For jsx, react
Plugin 'git@github.com:vim-syntastic/syntastic.git'
Plugin 'Conque-GDB' "You will need to install gdb for this
call vundle#end()
filetype plugin indent on
"////////////////////////////
"// Syntastic
set statusline+=%#warningmsg#
set statusline+=%{SyntasticStatuslineFlag()}
set statusline+=%*
let g:syntastic_always_populate_loc_list = 1
let g:syntastic_auto_loc_list = 1
let g:syntastic_check_on_open = 1
let g:syntastic_check_on_w = 1
let g:syntastic_check_on_wq = 1
let g:ycm_show_diagnostics_ui = 0 "not default - YCM blocks c/c++ linters by default, this allows it
let g:syntastic_c_checkers = ['avrgcc'] ", 'gcc']
"let g:syntastic_cpp_checkers = ['cppcheck'] " sudo apt-get install cppcheck
let g:syntastic_cs_checkers = ['syntax', 'semantic', 'issues'] " OmniSharp thing, see https://github.com/OmniSharp/omnisharp-vim#example-vimrc
let g:syntastic_javascript_checkers = ['eslint'] " To use es6 with React and the linter, do: https://jaxbot.me/articles/setting-up-vim-for-react-js-jsx-02-03-2015
let g:syntastic_json_checkers = ['eslint'] " ?? This not working, why???
let g:syntastic_python_checkers = ['pylint'] " sudo apt-get install pylint
let g:syntastic_python3_checkers = ['pylint3'] " sudo apt-get install pylint3
let g:syntastic_haskell_checkers = ['hlint'] " sudo apt-get install hlint
"//////////////////////////
"// YouCompleteMe
"// C++, C, C#, JavaScript, Python2+3
"// C# needs OmniSharp to work
" This line makes it work with C and C++
let g:ycm_global_ycm_extra_conf = "~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py"
let g:ycm_python_binary_path = '/usr/bin/python'
let g:ycm_python3_binary_path = '/usr/bin/python3'
" For working with ghc-mod, below
let g:ycm_semantic_triggers = {'haskell' : ['.']}
"////////////////////////////
"// ghc-mod
"// cabal install ghc-mod
"// Assists with YouCompleteMe
let g:haskellmode_completion_ghc = 0
autocmd FileType haskell setlocal omnifunc=necoghc#omnifunc
"////////////////////////////
"// CtrlP
let g:ctrlp_map = '<c-p>'
let g:ctrlp_cmd = 'CtrlP'
"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
set autochdir
set tags=tags;
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()
@JasonThomasData
Copy link
Author

JasonThomasData commented Aug 1, 2017

Regarding building vim, include this in the terminal install:

cd ~
git clone https://github.com/vim/vim.git
cd vim
./configure --with-features=huge \
            --enable-multibyte \
            --enable-rubyinterp=yes \
            --enable-pythoninterp=yes \
            --with-python-config-dir=/usr/lib/python2.7/config-x86_64-linux-gnu/ \
            --enable-perlinterp=yes \
            --enable-luainterp=yes \
            --enable-gui=gtk2 \
            --enable-cscope \
            --prefix=/usr/local
make VIMRUNTIMEDIR=/usr/local/share/vim/vim80
sudo apt-get install python-dev python3-dev
sudo make install

Make sure you remove the python3 interpreter with Linux Mint, and that the Python config path file is correct. I've tested this with Python3 and the OmniSharp installer will not recognise Python3.

Then, do the instructions for installing YouCompleteMe - https://github.com/Valloric/YouCompleteMe

@wgv-sethlivingston
Copy link

Make sure you remove the python3 interpreter with Linux Mint...

Does this mean I can't use this setup for python3 development? Cause that's what I'm doing. :)

@JasonThomasData
Copy link
Author

JasonThomasData commented Aug 24, 2017

You won't need to install OmniSharp at all if you're not doing C#. Also I use Linux Mint and have never tested this on another OS. That line in particular refers to the config options in omnisharp I think.

@JasonThomasData
Copy link
Author

On Mac, install MacVim as the guide says, but instead of including a simlink, put this in your bashrc:
alias vim="mvim -c :Vex"

@JasonThomasData
Copy link
Author

When compiling vim, if you get an error: no terminal library found
Then do:
sudo apt-get install libncurses5-dev libncursesw5-dev

@JasonThomasData
Copy link
Author

One time, the compile installed vim at /usr/local/bin/vim - so fix was to set Bash Alias for it

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