" this isn't the 90s anymore set nocompatible " Attempt to determine the type of a file based on its name and possibly its " contents. Use this to allow intelligent auto-indenting for each filetype, " and for plugins that are filetype specific. if has('filetype') filetype indent plugin on endif " Enable syntax highlighting if has('syntax') syntax on endif set encoding=utf-8 " Vim with default settings does not allow easy switching between multiple files " in the same editor window. Users can use multiple split windows or multiple " tab pages to edit multiple files, but it is still best to enable an option to " allow easier switching between files. " " One such option is the 'hidden' option, which allows you to re-use the same " window and switch from an unsaved buffer without saving it first. Also allows " you to keep an undo history for multiple files when re-using the same window " in this way. Note that using persistent undo also lets you undo in multiple " files even in the same window, but is less efficient and is actually designed " for keeping undo history after closing Vim entirely. Vim will complain if you " try to quit without saving, and swap files will keep you safe if your computer " crashes. set hidden " Better command-line completion set wildmenu " Show partial commands in the last line of the screen set showcmd " Highlight searches (use / to temporarily turn off highlighting) set hlsearch " Use case insensitive search, except when using capital letters set ignorecase set smartcase " Allow backspacing over autoindent, line breaks and start of insert action set backspace=indent,eol,start " When opening a new line and no filetype-specific indenting is enabled, keep " the same indent as the line you're currently on. Useful for READMEs, etc. set autoindent " Stop certain movements from always going to the first character of a line. " While this behaviour deviates from that of Vi, it does what most users " coming from other editors would expect. set nostartofline " Display the cursor position on the last line of the screen or in the status " line of a window set ruler " Always display the status line, even if only one window is displayed set laststatus=2 " Instead of failing a command because of unsaved changes, instead raise a " dialogue asking if you wish to save changed files. set confirm " Use visual bell instead of beeping when doing something wrong set visualbell " And reset the terminal code for the visual bell. If visualbell is set, and " this line is also included, vim will neither flash nor beep. If visualbell " is unset, this does nothing. set t_vb= " Enable use of the mouse for all modes if has('mouse') set mouse=a endif " Display line numbers on the left set number set relativenumber " Quickly time out on keycodes, but never time out on mappings set notimeout ttimeout ttimeoutlen=200 " Use to toggle between 'paste' and 'nopaste' set pastetoggle= " " Leave paste mode so I don't forget autocmd InsertLeave * set nopaste autocmd BufNewFile,BufRead *.asm setlocal ts=5 sts=5 sw=5 " Indentation settings for using 4 spaces instead of tabs. " Do not change 'tabstop' from its default value of 8 with this setup. set shiftwidth=4 set softtabstop=4 set expandtab " Don't update the screen when executing macros set lazyredraw " Easier to reach than \ let mapleader=" " " plugin config nmap (ale_previous_wrap) nmap (ale_next_wrap) " fzf nmap p :Files nmap bb :Buffers " lightline let g:lightline = { \ 'colorscheme': 'Tomorrow_Night', \ } let g:lightline.component_expand = { \ 'linter_checking': 'lightline#ale#checking', \ 'linter_infos': 'lightline#ale#infos', \ 'linter_warnings': 'lightline#ale#warnings', \ 'linter_errors': 'lightline#ale#errors', \ 'linter_ok': 'lightline#ale#ok', \ } let g:lightline.component_type = { \ 'linter_checking': 'right', \ 'linter_infos': 'right', \ 'linter_warnings': 'warning', \ 'linter_errors': 'error', \ 'linter_ok': 'right', \ } let g:lightline.active = { \ 'right': [ [ 'linter_checking', 'linter_errors', 'linter_warnings', 'linter_infos', 'linter_ok' ], \ [ 'lineinfo' ], \ [ 'percent' ], \ [ 'fileformat', 'fileencoding', 'filetype'] ] } let g:lightline#ale#indicator_checking = "\uf110" let g:lightline#ale#indicator_infos = "\uf129" let g:lightline#ale#indicator_warnings = "\uf071" let g:lightline#ale#indicator_errors = "\uf05e" let g:lightline#ale#indicator_ok = "\uf00c" " end plugin config set formatoptions=ctqrn1 set showmatch " Show matching brackets. set matchtime=5 " Bracket blinking. " start scrolling when we're 8 lines away from margins set scrolloff=8 set sidescrolloff=15 set sidescroll=1 set noswapfile set nobackup set nowb " Automatically insert the current comment leader after hitting 'o' or 'O' in Normal mode. "set fo+=o " Do not automatically insert a comment leader after an enter "set fo-=r " Do no auto-wrap text using textwidth (does not apply to comments) "set fo-=t set wildignore+=*/tmp/*,*.so,*.swp,*.zip,*/vendor/*,*/bin/*,*/node_modules/* " quicker async update time set updatetime=100 " taller vertical bar for vsplits set fillchars+=vert:│ set termguicolors set undodir=~/.vim/backups set undofile " When opening a file, always jump to the last cursor position autocmd BufReadPost * \ if line("'\"") > 0 && line ("'\"") <= line("$") | \ exe "normal g'\"" | \ endif " remove annoying help window inoremap nnoremap vnoremap " easy .vimrc editing nnoremap rs :source ~/.vimrc nnoremap rt :tabnew ~/.vimrc " better window navigation nnoremap j nnoremap k nnoremap h nnoremap l " quickfix nnoremap :cnext nnoremap :cprevious " command line autocomplete set wildchar= wildmenu wildmode=full " scroll through buffers noremap :bp noremap :bn " show menu to switch buffers set wildcharm= nnoremap :b " unhighlight search results noremap / :nohls " reselect visual block after indent/outdent vnoremap < >gv " force saving files that require root permission cmap w!! %!sudo tee > /dev/null % " Close the current buffer and move to the previous one " This replicates the idea of closing a tab nmap bq :bp bd # colorscheme base16-default-dark let g:ale_completion_enabled = 1 " Load all plugins now. " Plugins need to be added to runtimepath before helptags can be generated. " Load all of the helptags now, after plugins have been loaded. " All messages and errors will be ignored. packloadall | silent! helptags ALL function! s:on_lsp_buffer_enabled() abort " setlocal omnifunc=lsp#complete setlocal signcolumn=yes if exists('+tagfunc') | setlocal tagfunc=lsp#tagfunc | endif nmap gd (lsp-definition) nmap gs (lsp-document-symbol-search) nmap gS (lsp-workspace-symbol-search) nmap gr (lsp-references) nmap gi (lsp-implementation) nmap gD (lsp-type-definition) nmap rn (lsp-rename) nmap [g (lsp-previous-diagnostic) nmap ]g (lsp-next-diagnostic) nmap K (lsp-hover) nnoremap lsp#scroll(+4) nnoremap lsp#scroll(-4) let g:lsp_format_sync_timeout = 1000 autocmd! BufWritePre *.rs,*.go call execute('LspDocumentFormatSync') " refer to doc to add more commands endfunction augroup lsp_install au! " call s:on_lsp_buffer_enabled only for languages that has the server registered. autocmd User lsp_buffer_enabled call s:on_lsp_buffer_enabled() augroup END if executable('solargraph') " gem install solargraph au User lsp_setup call lsp#register_server({ \ 'name': 'solargraph', \ 'cmd': {server_info->[&shell, &shellcmdflag, 'solargraph stdio']}, \ 'initialization_options': {"diagnostics": "true"}, \ 'whitelist': ['ruby'], \ }) endif function! SmartInsertCompletion() abort " Use the default CTRL-N in completion menus if pumvisible() return "\" endif " Exit and re-enter insert mode, and use insert completion return "\a\" endfunction inoremap =SmartInsertCompletion() inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? "\" : "\" inoremap pumvisible() ? asyncomplete#close_popup() : "\" let g:termdebug_popup = 0 let g:termdebug_wide = 163 vnoremap d :DB set omnifunc=ale#completion#OmniFunc