Advertisement
kjetilcodes

init.vim

Feb 6th, 2019
681
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VIM 5.33 KB | None | 0 0
  1. "" neovim-settings
  2. " Setting tabs to 2 spaces
  3. "
  4. set tabstop=2 softtabstop=0 expandtab shiftwidth=2 smarttab
  5. set number                 
  6.  
  7. "" bind ALT + direction keys to switch windows
  8. nmap <silent> <M-k> :wincmd k<CR>
  9. nmap <silent> <M-j> :wincmd j<CR>
  10. nmap <silent> <M-h> :wincmd h<CR>
  11. nmap <silent> <M-l> :wincmd l<CR>
  12.  
  13. "" Binds space to esc
  14. nnoremap <C-Space> i
  15. inoremap <C-Space> <Esc>
  16.  
  17. "" Plugins
  18. call plug#begin('~/.local/share/nvim/plugged')
  19.  
  20.   Plug 'scrooloose/nerdtree'       " File-tree
  21.   Plug 'jiangmiao/auto-pairs'        " Auto-pairing brackets
  22.   Plug 'mattn/emmet-vim'                 " Emmet
  23.   Plug 'pangloss/vim-javascript' " JavaScript syntax-highlighting
  24.   Plug 'mxw/vim-jsx'                         " JSX syntax-highlighting
  25.   Plug 'alampros/vim-styled-jsx' " Emmet-snippets for style-jsx
  26.   Plug 'w0rp/ale'                                " Linter
  27.   Plug 'SirVer/ultisnips'            " Snippetsmanager
  28.     Plug 'honza/vim-snippets'        " Snippets to go with ultisnips
  29.     Plug 'ervandew/supertab'             " Tool to make tab usable between plugins
  30.     Plug 'wokalski/autocomplete-flow' " Enables tab completion for everything, blazing fast
  31.                                                        " post install (yarn install | npm install) then load plugin only for editing supported files
  32. Plug 'prettier/vim-prettier', {
  33.   \ 'do': 'yarn install',
  34.   \ 'for': ['javascript', 'typescript', 'css', 'less', 'scss', 'json', 'graphql', 'markdown', 'vue', 'yaml', 'html'] }
  35.  
  36. Plug 'vim-airline/vim-airline'  " Theme for status bar etc
  37. Plug 'vim-airline/vim-airline-themes' " Additional themes for airline
  38. Plug 'edkolev/tmuxline.vim'         " tmux-line, gives TMUX airline-theme
  39. Plug 'ryanoasis/vim-devicons'   " Devicons <3
  40. Plug 'Valloric/YouCompleteMe' " Snippets
  41. call plug#end()
  42.  
  43. """ AutocompleteFlow settings
  44. let g:autocomplete_flow#insert_paren_after_function = 0
  45.  
  46. """ Nerdtree settings
  47. "  Set nerdtree to open when nvim opens
  48.   autocmd vimenter * NERDTree
  49.  
  50. "  Set nerdtree to open, even if no filename was specified
  51.   autocmd StdinReadPre * let s:std_in=1
  52.   autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
  53. " Exit vim if nerdtree is the only window open
  54.   autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTree") && b:NERDTree.isTabTree()) | q | endif
  55. " NERDTree File highlighting
  56. map <C-M-O> :NERDTreeToggle<CR>
  57.  
  58. function! NERDTreeHighlightFile(extension, fg, bg, guifg, guibg)
  59.  exec 'autocmd filetype nerdtree highlight ' . a:extension .' ctermbg='. a:bg .' ctermfg='. a:fg .' guibg='. a:guibg .' guifg='. a:guifg
  60.  exec 'autocmd filetype nerdtree syn match ' . a:extension .' #^\s\+.*'. a:extension .'$#'
  61. endfunction
  62.  
  63. call NERDTreeHighlightFile('jade', 'green', 'none', 'green', '#151515')
  64. call NERDTreeHighlightFile('ini', 'yellow', 'none', 'yellow', '#151515')
  65. call NERDTreeHighlightFile('md', 'blue', 'none', '#3366FF', '#151515')
  66. call NERDTreeHighlightFile('yml', 'yellow', 'none', 'yellow', '#151515')
  67. call NERDTreeHighlightFile('config', 'yellow', 'none', 'yellow', '#151515')
  68. call NERDTreeHighlightFile('conf', 'yellow', 'none', 'yellow', '#151515')
  69. call NERDTreeHighlightFile('json', 'yellow', 'none', 'yellow', '#151515')
  70. call NERDTreeHighlightFile('html', 'yellow', 'none', 'yellow', '#151515')
  71. call NERDTreeHighlightFile('styl', 'cyan', 'none', 'cyan', '#151515')
  72. call NERDTreeHighlightFile('css', 'cyan', 'none', 'cyan', '#151515')
  73. call NERDTreeHighlightFile('coffee', 'Red', 'none', 'red', '#151515')
  74. call NERDTreeHighlightFile('js', 'Red', 'none', '#ffa500', '#151515')
  75. call NERDTreeHighlightFile('php', 'Magenta', 'none', '#ff00ff', '#151515')
  76.  
  77.  
  78.  
  79. """ emmet-vim settings
  80. " Makes it pleasant to use with jsx files
  81.   let g:user_emmet_settings = {
  82.     \  'javascript.jsx' : {
  83.       \      'extends' : 'jsx',
  84.       \  },
  85.     \}
  86.  
  87. """ ale settings
  88. " some tweaks to make it less agressive
  89.   let g:ale_sign_error = '●' " Less aggressive than the default '>>'
  90.   let g:ale_sign_warning = '.'
  91.   let g:ale_lint_on_enter = 0 " Less distracting when opening a new file
  92.     let g:ale_lint_on_save = 1
  93.     let g:ale_lint_on_text_changed = 0
  94.  
  95.  
  96. """ prettier settings
  97.   let g:prettier#quickfix_enabled = 0 " Disable quickfix
  98.   let g:prettier#quickfix_auto_focus = 0 " Disables focus on quickfix ( Might be overkill )
  99.   let g:prettier#autoformat = 0 " Stops formatting, triggering async-formatting in command below
  100.   autocmd BufWritePre *.js,*.jsx,*.mjs,*.ts,*.tsx,*.css,*.less,*.scss,*.json,*.graphql,*.md,*.vue,*.yaml,*.html PrettierAsync
  101.   let g:prettier#config#semi = 'true' " Disables auto-insert of ;
  102.   let g:prettier#config#single_quote = 'true' " Changes doublequotes to singles on format
  103.   let g:prettier#config#trailing_comma = 'none' " disable auto-insert comma's
  104.   let g:prettier#config#config_precedence = 'prefer-file'
  105.  
  106. """  Ultisnips settings
  107.   let g:UltiSnipsSnippetDirectories = ['/home/kjetil/Documents/Configs/UltiSnips', 'UltiSnips']
  108.         "" better key bindings for UltiSnipsExpandTrigger
  109. let g:UltiSnipsExpandTrigger = "<tab>"
  110. let g:UltiSnipsJumpForwardTrigger = "<tab>"
  111. let g:UltiSnipsJumpBackwardTrigger = "<s-tab>"
  112.  
  113.  
  114. """ Vim-airline settings
  115. let g:airline_powerline_fonts = 1
  116. let g:airline_theme='murmur'
  117.  
  118. """ YCM settings
  119.         " make YCM compatible with UltiSnips (using supertab)
  120. let g:ycm_key_list_select_completion = ['<C-n>', '<Down>']
  121. let g:ycm_key_list_previous_completion = ['<C-p>', '<Up>']
  122. let g:SuperTabDefaultCompletionType = '<C-n>'
  123.  
  124. if exists("g:loaded_webdevicons")
  125.   call webdevicons#refresh()
  126. endif
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement