Skip to content

Instantly share code, notes, and snippets.

@emiflake
Created September 11, 2019 19:50
Show Gist options
  • Save emiflake/742f7c15f75718c7ff1a5988a8a0ad0b to your computer and use it in GitHub Desktop.
Save emiflake/742f7c15f75718c7ff1a5988a8a0ad0b to your computer and use it in GitHub Desktop.
let mapleader=","
set nocompatible
filetype off
"let base16colorspace=256
set termguicolors
let g:loaded_matchit = 1
" ============================================== "
" "
" P L U G I N S "
" "
" ============================================== "
call plug#begin()
" Base16 colours
Plug 'chriskempson/base16-vim'
" Editor config support
Plug 'editorconfig/editorconfig-vim'
" Git gutter support
Plug 'airblade/vim-gitgutter'
" Aesthetically pleasing bottom bar
Plug 'itchyny/lightline.vim'
" Automatically highlight what we just yanked
Plug 'machakann/vim-highlightedyank'
" The one way to search
Plug 'airblade/vim-rooter'
Plug 'kien/ctrlp.vim'
Plug 'jremmen/vim-ripgrep'
Plug 'HerringtonDarkholme/yats.vim'
Plug 'ncm2/nvim-typescript', {'do': './install.sh'}
Plug 'prettier/vim-prettier', {
\ 'do': 'yarn install',
\ 'branch': 'release/1.x',
\ 'for': [
\ 'javascript',
\ 'typescript',
\ 'css',
\ 'less',
\ 'scss',
\ 'json',
\ 'html' ] }
" Toml langauge support
Plug 'cespare/vim-toml'
" Actually go to matching stuff
Plug 'andymass/vim-matchup'
Plug 'scrooloose/nerdcommenter'
Plug 'ntpeters/vim-better-whitespace'
nmap <Leader>f :StripWhitespace<CR>
" Formatting
Plug 'Chiel92/vim-autoformat'
" Linting
Plug 'dense-analysis/ale'
" LSP/Autocomplete
Plug 'autozimu/LanguageClient-neovim', {
\ 'branch': 'next',
\ 'do': 'bash install.sh'
\ }
Plug 'ncm2/ncm2'
Plug 'roxma/nvim-yarp'
Plug 'ncm2/ncm2-path'
Plug 'ncm2/ncm2-pyclang'
Plug 'ron-rs/ron.vim'
" Discord, because why not
"Plug 'aurieh/discord.nvim', { 'do': ':UpdateRemotePlugins'}
call plug#end()
" Linter
let g:ale_lint_on_text_changed = 'never'
let g:ale_lint_on_insert_leave = 0
let g:ale_lint_on_save = 1
let g:ale_lint_on_enter = 0
let g:ale_virtualtext_cursor = 1
let g:ale_rust_rls_config = {
\ 'rust': {
\ 'all_targets': 1,
\ 'build_on_save': 1,
\ 'clippy_preference': 'on'
\ }
\ }
let g:ale_rust_rls_toolchain = ''
let g:ale_linters = {'rust': ['rls'], 'c': ['clang', 'clangd']}
highlight link ALEWarningSign Todo
highlight link ALEErrorSign WarningMsg
highlight link ALEVirtualTextWarning Todo
highlight link ALEVirtualTextInfo Todo
highlight link ALEVirtualTextError WarningMsg
highlight ALEError guibg=None
highlight ALEWarning guibg=None
let g:ale_sign_error = "✖"
let g:ale_sign_warning = "⚠"
let g:ale_sign_info = "i"
let g:ale_sign_hint = "➤"
nnoremap <silent> K :ALEHover<CR>
nnoremap <silent> gd :ALEGoToDefinition<CR>
nnoremap <silent> gs :ALEGoToDefinitionInSplit<CR>
let g:rustfmt_command = "rustfmt +nightly"
let g:rustfmt_autosave = 1
let g:rustfmt_emit_files = 1
let g:rustfmt_fail_silently = 0
let $RUST_SRC_PATH = systemlist("rustc --print sysroot")[0] . "/lib/rustlib/src/rust/src"
" Completion
" Clang for C/C++
let g:ncm2_pyclang#library_path = '/Library/Developer/CommandLineTools/usr/lib/libclang.dylib'
let g:ncm2_pyclang#args_file_path = ['.clang_complete']
let g:ncm2_pyclang#database_path = [
\ 'compile_commands.json',
\ 'build/compile_commands.json'
\ ]
autocmd FileType c,cpp nnoremap <buffer> gd :<c-u>call ncm2_pyclang#goto_declaration()<cr>
autocmd BufEnter * call ncm2#enable_for_buffer()
set completeopt=noinsert,menuone,noselect
" tab to select
" and don't hijack my enter key
inoremap <expr><Tab> (pumvisible()?(empty(v:completed_item)?"\<C-n>":"\<C-y>"):"\<Tab>")
inoremap <expr><CR> (pumvisible()?(empty(v:completed_item)?"\<CR>":"\<C-y>"):"\<CR>")
let g:LanguageClient_serverCommands = {
\ 'rust': ['~/.cargo/bin/rustup', 'run', 'stable', 'rls'],
\ }
nnoremap <F5> :call LanguageClient_contextMenu()<CR>
"nnoremap <silent> K :call LanguageClient#textDocument_hover()<CR>
"nnoremap <silent> gd :call LanguageClient#textDocument_definition()<CR>
nnoremap <silent> <F2> :call LanguageClient#textDocument_rename()<CR>
" Formatting
let g:autoformat_autoindent = 0
let g:autoformat_retab = 0
let g:autoformat_remove_trailing_spaces = 0
let g:formatdef_rustfmt = '"rustfmt"'
let g:formatters_rust = ['rustfmt']
au BufWrite * :Autoformat
au BufEnter * :GitGutterEnable
au BufWrite * :GitGutter
" ============================================== "
" "
" E D I T O R C F G "
" "
" ============================================== "
filetype plugin indent on
set autoindent
set timeoutlen=300 " New line with `o` delay
set encoding=utf-8
set clipboard=unnamedplus " Share clipboard with MacOS
set scrolloff=2
set noshowmode
set hidden
set nowrap
set mouse=a
set number
set splitright
set splitbelow
" Permanent undo @ ~./vimdid
set undodir=~/.vimdid
set undofile
set shiftwidth=8
set softtabstop=8
set tabstop=8
set noexpandtab
set ruler
set ttyfast
set nolist
set listchars=nbsp:¬,extends:»,precedes:«,trail:•
nnoremap j gj
nnoremap k gk
" Never again
map <F1> <Esc>
imap <F1> <Esc>
" Tmux-like splits
nmap <C-a>\| :vsp<CR>
nmap <C-a>- :sp<CR>
nmap <Leader>h :Stdheader<CR>
colorscheme base16-atelier-cave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment