Last active
December 16, 2018 09:37
-
-
Save niklasad1/efe816a59c023c156f0dee9f9fee2a5a to your computer and use it in GitHub Desktop.
nvim config
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
call plug#begin('~/.vim/plugged') | |
Plug 'editorconfig/editorconfig-vim' | |
Plug 'ncm2/ncm2' | |
Plug 'roxma/nvim-yarp' | |
Plug 'ncm2/ncm2-racer' | |
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeToggle' } | |
Plug 'scrooloose/nerdcommenter' | |
Plug 'Chiel92/vim-autoformat' | |
Plug 'vim-syntastic/syntastic' | |
Plug 'rust-lang/rust.vim' | |
Plug 'autozimu/LanguageClient-neovim', { | |
\ 'branch': 'next', | |
\ 'do': 'bash install.sh', | |
\ } | |
Plug 'Shougo/deoplete.nvim', { 'do': ':UpdateRemotePlugins' } | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'kien/ctrlp.vim' | |
Plug 'harenome/vim-mipssyntax' | |
call plug#end() | |
" On-demand loading | |
set number | |
set hidden | |
syntax on | |
filetype on | |
filetype plugin on | |
filetype indent on | |
" leader mapping | |
let mapleader = "-" | |
" color scheme | |
let g:molokai_orginal = 1 | |
" display settings | |
set encoding=utf-8 " encoding used for displaying file | |
set ruler " show the cursor position all the time | |
set showmatch " highlight matching braces | |
set showmode " show insert/replace/visual mode | |
" whitespace chars | |
set listchars=eol:¬,tab:>·,trail:~,extends:>,precedes:<,space:␣ | |
" Use tabs as `tabs` | |
set autoindent | |
set expandtab | |
set tabstop=4 | |
set softtabstop=4 | |
set shiftwidth=4 | |
" Text width | |
set textwidth=80 | |
" Yank to clipboard | |
set clipboard+=unnamedplus | |
" enable mouse | |
set mouse=a | |
" search settings | |
set hlsearch " highlight search results | |
set ignorecase " do case insensitive search... | |
set incsearch " do incremental search | |
set smartcase " ...unless capital letters are used | |
" enable ncm2 for all buffers | |
autocmd BufEnter * call ncm2#enable_for_buffer() | |
autocmd BufReadPost *.rs setlocal filetype=rust | |
" IMPORTANT: :help Ncm2PopupOpen for more information | |
set completeopt=noinsert,menuone,noselect | |
" nerdcommenter | |
let g:NERDSpaceDelims = 1 " Add spaces after comment delimiters by default | |
let g:NERDCompactSexyComs = 1 " Use compact syntax for prettified multi-line comments | |
let g:NERDDefaultAlign = 'left' " Align line-wise comment delimiters flush left instead of following code indentation | |
let g:NERDAltDelims_java = 1 " Set a language to use its alternate delimiters by default | |
let g:NERDCustomDelimiters = { 'c': { 'left': '/**','right': '*/' } } " Add your own custom formats or override the defaults | |
let g:NERDCommentEmptyLines = 1 " Allow commenting and inverting empty lines (useful when commenting a region) | |
let g:NERDTrimTrailingWhitespace = 1 " Enable trimming of trailing whitespace when uncommenting | |
" 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:ctrlp_user_command = 'find %s -type f' | |
let g:syntastic_check_on_wq = 0 | |
" CtrlP | |
let g:ctrlp_user_command = ['.git', 'cd %s && git ls-files . -co --exclude-standard', 'find %s -type f'] | |
" Compile and run by entering -r | |
nnoremap <leader>r :call CompileRunGcc()<CR> | |
" Autoformat, tabs etc | |
nnoremap <leader>a :Autoformat<CR> | |
" Toggle Folding | |
nnoremap <leader>f za<CR> | |
" Copy the entire file | |
nnoremap <leader>ac ggmqvG"+y'q | |
" Toogle `list` | |
nnoremap <leader>v :set list!<CR> | |
" Spell check | |
nnoremap <leader>s :setlocal spell!<cr> | |
" Easier navigation | |
nnoremap <C-Down> <C-W><C-J> | |
nnoremap <C-Up> <C-W><C-K> | |
nnoremap <C-Right> <C-W><C-L> | |
nnoremap <C-Left> <C-W><C-H> | |
func! CompileRunGcc() | |
exec "w" | |
exec "!clear" | |
if &filetype == 'c' | |
exec "!gcc -g -Wall -pedantic -std=c99 % -o %<" | |
exec "!time ./%<" | |
elseif &filetype == 'python' | |
exec "!python3 %" | |
elseif &filetype == 'cpp' | |
exec "!g++ % -o %<" | |
exec "!time ./%<" | |
elseif &filetype == 'java' | |
exec "!javac %" | |
exec "!time java -cp %:p:h %:t:r" | |
elseif &filetype == 'sh' | |
exec "!time bash %" | |
elseif &filetype == 'html' | |
exec "!firefox % &" | |
elseif &filetype == 'go' | |
exec "!go build %<" | |
exec "!time go run %" | |
elseif &filetype == 'mkd' | |
exec "!~/.vim/markdown.pl % > %.html &" | |
exec "!firefox %.html &" | |
elseif &filetype == 'erlang' | |
exec "!make debug" | |
exec "!erl" | |
elseif &filetype == 'rust' | |
exec "!cargo check" | |
endif | |
endfunc | |
" Delete trailing white space on save, useful for some filetypes ;) | |
fun! CleanExtraSpaces() | |
let save_cursor = getpos(".") | |
let old_query = getreg('/') | |
silent! %s/\s\+$//e | |
call setpos('.', save_cursor) | |
call setreg('/', old_query) | |
endfun | |
if has("autocmd") | |
autocmd BufWritePre *.txt,*.js,*.py,*.wiki,*.sh,*.rs,*.c,*.cpp :call CleanExtraSpaces() | |
endif | |
let g:LanguageClient_serverCommands = { | |
\ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'], | |
\ 'javascript': ['/usr/local/bin/javascript-typescript-stdio'], | |
\ 'javascript.jsx': ['tcp://127.0.0.1:2089'], | |
\ 'python': ['/usr/local/bin/pyls'], | |
\ } | |
nnoremap <F5> :call LanguageClient_contextMenu()<CR> | |
" Or map each action separately | |
nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR> | |
nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR> | |
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment