Created
April 25, 2020 04:20
-
-
Save AdvaithD/d16fd190a15bc36ff346b19658577318 to your computer and use it in GitHub Desktop.
neovim setup
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(stdpath('data') . '/plugged') | |
" Plug 'dracula/vim' " Theme | |
" Plug 'morhetz/gruvbox' | |
Plug 'drewtempelmeyer/palenight.vim' | |
Plug 'scrooloose/nerdtree' " file explorer | |
Plug 'ryanoasis/vim-devicons' | |
Plug 'junegunn/fzf', { 'dir': '~/.fzf', 'do': './install --all' } | |
Plug 'junegunn/fzf.vim' | |
Plug 'airblade/vim-gitgutter' | |
Plug 'vim-airline/vim-airline' | |
Plug 'vim-airline/vim-airline-themes' | |
Plug 'tmsvg/pear-tree' | |
Plug 'tpope/vim-fugitive' | |
Plug 'frazrepo/vim-rainbow' | |
Plug 'itchyny/vim-cursorword' | |
" start screen | |
Plug 'mhinz/vim-startify' | |
" above two are for file searching | |
" below are ts stuff | |
Plug 'neoclide/coc.nvim', {'branch': 'release'} | |
let g:coc_global_extensions = ['coc-emmet', 'coc-css', 'coc-html', 'coc-json', 'coc-prettier', 'coc-tsserver', 'coc-eslint'] | |
" typescript tsx | |
Plug 'leafgarland/typescript-vim' | |
Plug 'peitalin/vim-jsx-typescript' | |
function! BuildComposer(info) | |
if a:info.status != 'unchanged' || a:info.force | |
if has('nvim') | |
!cargo build --release --locked | |
else | |
!cargo build --release --locked --no-default-features --features json-rpc | |
endif | |
endif | |
endfunction | |
Plug 'euclio/vim-markdown-composer', { 'do': function('BuildComposer') } | |
call plug#end() | |
" from missing-semester-cs | |
" Turn on syntax highlighting. | |
syntax on | |
" Disable the default Vim startup message. | |
set shortmess+=I | |
" Show line numbers. | |
set number | |
" font | |
" This enables relative line numbering mode. With both number and | |
" relativenumber enabled, the current line shows the true line number, while | |
" all other lines (above and below) are numbered relative to the current line. | |
" This is useful because you can tell, at a glance, what count is needed to | |
" jump up or down to a particular line, by {count}k to go up or {count}j to go | |
" down. | |
set relativenumber | |
" Always show the status line at the bottom, even if you only have one window open. | |
set laststatus=2 | |
" The backspace key has slightly unintuitive behavior by default. For example, | |
" by default, you can't backspace before the insertion point set with 'i'. | |
" This configuration makes backspace behave more reasonably, in that you can | |
" backspace over anything. | |
set backspace=indent,eol,start | |
" By default, Vim doesn't let you hide a buffer (i.e. have a buffer that isn't | |
" shown in any window) that has unsaved changes. This is to prevent you from " | |
" forgetting about unsaved changes and then quitting e.g. via `:qa!`. We find | |
" hidden buffers helpful enough to disable this protection. See `:help hidden` | |
" for more information on this. | |
set hidden | |
" This setting makes search case-insensitive when all characters in the string | |
" being searched are lowercase. However, the search becomes case-sensitive if | |
" it contains any capital letters. This makes searching more convenient. | |
set ignorecase | |
set smartcase | |
" Enable searching as you type, rather than waiting till you press enter. | |
set incsearch | |
" Unbind some useless/annoying default key bindings. | |
nmap Q <Nop> " 'Q' in normal mode enters Ex mode. You almost never want this. | |
" Disable audible bell because it's annoying. | |
set noerrorbells visualbell t_vb= | |
" Enable mouse support. You should avoid relying on this too much, but it can | |
" sometimes be convenient. | |
set mouse+=a | |
" Try to prevent bad habits like using the arrow keys for movement. This is | |
" not the only possible bad habit. For example, holding down the h/j/k/l keys | |
" for movement, rather than using more efficient movement commands, is also a | |
" bad habit. The former is enforceable through a .vimrc, while we don't know | |
" how to prevent the latter. | |
" Do this in normal mode... | |
nnoremap <Left> :echoe "Use h"<CR> | |
nnoremap <Right> :echoe "Use l"<CR> | |
nnoremap <Up> :echoe "Use k"<CR> | |
nnoremap <Down> :echoe "Use j"<CR> | |
" ...and in insert mode | |
inoremap <Left> <ESC>:echoe "Use h"<CR> | |
inoremap <Right> <ESC>:echoe "Use l"<CR> | |
inoremap <Up> <ESC>:echoe "Use k"<CR> | |
inoremap <Down> <ESC>:echoe "Use j"<CR> | |
" missing semester end | |
" coc start | |
" TextEdit might fail if hidden is not set. | |
set hidden | |
" Some servers have issues with backup files, see #649. | |
set nobackup | |
set nowritebackup | |
" Give more space for displaying messages. | |
set cmdheight=2 | |
" Having longer updatetime (default is 4000 ms = 4 s) leads to noticeable | |
" delays and poor user experience. | |
set updatetime=300 | |
" Don't pass messages to |ins-completion-menu|. | |
set shortmess+=c | |
" Always show the signcolumn, otherwise it would shift the text each time | |
" diagnostics appear/become resolved. | |
set signcolumn=yes | |
" Add (Neo)Vim's native statusline support. | |
" NOTE: Please see `:h coc-status` for integrations with external plugins that | |
" provide custom statusline: lightline.vim, vim-airline. | |
set statusline^=%{coc#status()}%{get(b:,'coc_current_function','')} | |
" coc end | |
" colorscheme gruvbox | |
let g:NERDTreeIndicatorMapCustom = { | |
\ "Modified" : "✹", | |
\ "Staged" : "✚", | |
\ "Untracked" : "✭", | |
\ "Renamed" : "➜", | |
\ "Unmerged" : "═", | |
\ "Deleted" : "", | |
\ "Dirty" : "✗", | |
\ "Clean" : "✔︎", | |
\ 'Ignored' : '☒', | |
\ "Unknown" : "?" | |
\ } | |
" fileexplorer and icon config | |
let g:NERDTreeShowHidden = 1 | |
let g:NERDTreeMinimalUI = 1 | |
let g:NERDTreeIgnore = [] | |
let g:NERDTreeStatusline = '' | |
" Automaticaly close nvim if NERDTree is only thing left open | |
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif | |
" Toggle | |
nnoremap <silent> <C-b> :NERDTreeToggle<CR> | |
" Integrated terminal | |
" open new split panes to right and below | |
set splitright | |
set splitbelow | |
" turn terminal to normal mode with escape | |
tnoremap <Esc> <C-\><C-n> | |
" start terminal in insert mode | |
au BufEnter * if &buftype == 'terminal' | :startinsert | endif | |
" open terminal on ctrl+n | |
function! OpenTerminal() | |
split term://zsh | |
resize 10 | |
endfunction | |
nnoremap <c-n> :call OpenTerminal()<CR> | |
" ZSH for terminal | |
set shell=/bin/zsh | |
" Switching between panels | |
" use alt+hjkl to move between split/vsplit panels | |
" Removed in favor of line 153 | |
" line 5 and 6 config file explorer | |
nnoremap <C-p> :FZF<CR> | |
let g:fzf_action = { | |
\ 'ctrl-t': 'tab split', | |
\ 'ctrl-s': 'split', | |
\ 'ctrl-v': 'vsplit' | |
\} | |
" ignore node_modules | |
let $FZF_DEFAULT_COMMAND = 'ag -g ""' | |
set cmdheight=2 | |
set tabstop=2 | |
set softtabstop=2 | |
set shiftwidth=2 | |
set smarttab | |
set expandtab | |
let g:gitgutter_sign_added = '✚' | |
let g:gitgutter_sign_modified = '✹' | |
let g:gitgutter_sign_removed = '-' | |
let g:gitgutter_sign_removed_first_line = '-' | |
let g:gitgutter_sign_modified_removed = '-' | |
" THEME | |
let g:airline_powerline_fonts = 1 | |
set background=dark | |
colorscheme palenight | |
" Italics for my favorite color scheme | |
let g:palenight_terminal_italics=1 | |
if (has("termguicolors")) | |
set termguicolors | |
endif | |
syntax enable | |
" bracket pairing | |
" Default rules for matching: | |
let g:pear_tree_pairs = { | |
\ '(': {'closer': ')'}, | |
\ '[': {'closer': ']'}, | |
\ '{': {'closer': '}'}, | |
\ "'": {'closer': "'"}, | |
\ '"': {'closer': '"'} | |
\ } | |
" See pear-tree/after/ftplugin/ for filetype-specific matching rules | |
" Pear Tree is enabled for all filetypes by default: | |
let g:pear_tree_ft_disabled = [] | |
" Pair expansion is dot-repeatable by default: | |
let g:pear_tree_repeatable_expand = 1 | |
" Smart pairs are disabled by default: | |
let g:pear_tree_smart_openers = 1 | |
let g:pear_tree_smart_closers = 1 | |
let g:pear_tree_smart_backspace = 1 | |
" If enabled, smart pair functions timeout after 60ms: | |
let g:pear_tree_timeout = 60 | |
" Automatically map <BS>, <CR>, and <Esc> | |
let g:pear_tree_map_special_keys = 1 | |
" Use ctrl-[hjkl] to select the active split! | |
nmap <silent> <c-k> :wincmd k<CR> | |
nmap <silent> <c-j> :wincmd j<CR> | |
nmap <silent> <c-h> :wincmd h<CR> | |
nmap <silent> <c-l> :wincmd l<CR> | |
if exists("g:loaded_webdevicons") | |
call webdevicons#refresh() | |
endif | |
" hover documentation tooltip | |
nnoremap <silent> K :call CocAction('doHover')<CR> | |
" diagonistics | |
function! ShowDocIfNoDiagnostic(timer_id) | |
if (coc#util#has_float() == 0) | |
silent call CocActionAsync('doHover') | |
endif | |
endfunction | |
function! s:show_hover_doc() | |
call timer_start(500, 'ShowDocIfNoDiagnostic') | |
endfunction | |
autocmd CursorHoldI * :call <SID>show_hover_doc() | |
autocmd CursorHold * :call <SID>show_hover_doc() | |
nnoremap <silent> <space>d :<C-u>CocList diagnostics<cr> | |
nnoremap <silent> <space>s :<C-u>CocList -I symbols<cr> | |
" performing auto code changes or fixes for linter issues | |
nmap <leader>do <Plug>(coc-codeaction) | |
" Nerdtree file highlighting | |
" NERDTrees File highlighting only the glyph/icon | |
" test highlight just the glyph (icons) in nerdtree: | |
autocmd filetype nerdtree highlight haskell_icon ctermbg=none ctermfg=Red guifg=#ffa500 | |
autocmd filetype nerdtree highlight html_icon ctermbg=none ctermfg=Red guifg=#ffa500 | |
autocmd filetype nerdtree highlight go_icon ctermbg=none ctermfg=Red guifg=#ffa500 | |
autocmd filetype nerdtree syn match haskell_icon ## containedin=NERDTreeFile | |
" if you are using another syn highlight for a given line (e.g. | |
" NERDTreeHighlightFile) need to give that name in the 'containedin' for this | |
" other highlight to work with it | |
autocmd filetype nerdtree syn match html_icon ## containedin=NERDTreeFile,html | |
autocmd filetype nerdtree syn match go_icon ## containedin=NERDTreeFile |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment